, a code gallery for creating, saving and sharing all kinds of code snippets.

URL Validation — PHP

Posted On: Saturday, May 10, 2014 at 9:56 AM

Snippet to validate a url

$url = '';
$validation = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);

if ( $validation ) $output = 'proper URL';
else $output = 'wrong URL';

echo $output;

You need to be logged in to comment! x


Joined on Saturday, May 3, 2014
Contributed 29 Snippets

Get Social and Share