PHP (RegEx) IP Address Validation


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. }

URL: http://www.thejwalker.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.