Posted By

manishwebginger on 03/01/14


Tagged

php


Versions (?)

How to Validate IP Address in PHP


 / Published in: PHP
 

php

  1. <?php
  2. $ip_address = '127.0.0.1';
  3.  
  4. if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $ip_address)){
  5. echo 'IP address is valid!';
  6. }else{
  7. echo 'IP address is NOT valid!';
  8. }

Report this snippet  

You need to login to post a comment.