Advertisement
tolikpunkoff

validate IP (with regexp)

Jul 26th, 2018
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.32 KB | None | 0 0
  1. //...
  2. $ip_pattern="#(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)#";
  3. //...
  4.  
  5. function isip($ip_str) //соответствие данных формату IP
  6. {  
  7.     global $ip_pattern;
  8.     $ret=FALSE;
  9.     if (preg_match($ip_pattern,$ip_str))
  10.     {
  11.         $ret=TRUE;
  12.     }
  13.     return $ret;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement