Validation::url PHP Method

url() public static method

public static url ( $value )
    public static function url($value)
    {
        return filter_var($value, FILTER_VALIDATE_URL) !== false;
    }

Usage Example

 public function beforeSave($options = array())
 {
     // add http:// if not present in webpage
     $webpage = $this->data['Registrant']['webpage'];
     $V = new Validation();
     if (!empty($webpage) && $V->url($webpage) && !$V->url($webpage, true)) {
         $this->data['Registrant']['webpage'] = 'http://' . $webpage;
     }
     // generate edit key
     if (empty($this->data['Registrant']['edit_key'])) {
         $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
         $this->data['Registrant']['edit_key'] = substr(str_shuffle($chars), 0, 8);
     }
     return true;
 }
All Usage Examples Of Validation::url