Posted By

jnbn on 10/11/09


Tagged

Expression regexpregular


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

silentbob84


Validate Domain Name


 / Published in: PHP
 

  1. $url = "http://komunitasweb.com/";
  2. if (preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?/i', $url)) {
  3. echo "Your url is ok.";
  4. } else {
  5. echo "Wrong url.";
  6. }

Report this snippet  

You need to login to post a comment.