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 = "";
  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


RSS Icon Subscribe to comments

You need to login to post a comment.