URL Validation

<?php

   $email = "some_url.com";

   if(preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)?([-а-яa-z0-9_\.]{2,}\.(рф|[a-z]{2,6}))((\/[-а-яa-z0-9_]{1,}\/)|(\/[-а-яa-z0-9_]{1,}\/)([-а-яa-z0-9_]{2,}\.(рф|[a-z]{2,6})))?((\?[a-z0-9_]{2,}=[-0-9]{1,})?((\&[a-z0-9_]{2,}=[-0-9]{1,}){1,})?)?/i ", $email))
   {
       echo 'This is a valid url.';
   }
   else
   {
       echo 'This is an invalid url.';
   }
?>

Do you find this helpful?

Related articles