Validate a url with PHP
Free Scripts :: PHP :: Validation :: Validate a url with PHP
Author: Salman Javaid
Website: http://www.salman.be
Website: http://www.salman.be
- Validate a url with php.
- How to validate a url with php.
- Validate a url with php.
Function accepts a parameter and returns false if value is not a valid url.
Function
function isValidUrl($string){
if(!preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?/i', $string)){
return false;
}
}
Calling The Function
$string=5;
if(isValidUrl($string)!==false){
echo 'Value is a valid url';
}else{
echo 'Value is not a valid url';
}
Output
Value is a valid url




