|
Check that a URL or website address is valid using preg_match().
-
<?php
-
-
$url = 'http://www.evilwalrus.org';
-
-
$urlValid = preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
-
-
if($urlValid) {
-
echo 'URL is valid!'; // this will display
-
} else {
-
echo 'Something is wrong with the URL';
-
}
-
-
?>
|