We have 44 guests online
PHP Scripts arrow Free PHP Tutorials arrow Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP 
Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP

URL Validation
User Rating: / 6
PoorBest 

Check that a URL or website address is valid using preg_match().

  1. <?php
  2.  
  3. $url = 'http://www.evilwalrus.org';
  4.  
  5. $urlValid = preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
  6.  
  7. if($urlValid) {
  8.     echo 'URL is valid!'// this will display
  9. } else {
  10.     echo 'Something is wrong with the URL';
  11. }
  12.  
  13. ?>

 

 

Directory Stats

There are 1036 listing and 46 categories in our website

Change Language