Posted By

aristoworks on 07/01/08


Tagged

php validation regular expressions ip address


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

jdstraughan
DeathfireD
robe
LeeRJohnson


PHP (RegEx) IP Address Validation


 / Published in: PHP
 

URL: http://www.thejwalker.com

A simple method of validating an IP address using PHP and regular expressions

  1. $string = "255.255.255.255";
  2. '/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/',
  3. $string)) {
  4. echo "IP address is good.";
  5. }

Report this snippet  

You need to login to post a comment.