note 51683 added to function.preg-match
| From: | maxatclnetdotcz at osu1 dot php dot net | Date: | Thu, 07 Apr 2005 14:40:47 +0000 |
| Subject: | note 51683 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87656@lists.php.net to get a copy of this message | ||
satch666 writed fix for the function valid_ipv4(), but it's not working good. I think that this
code is realy functionaly.
<?
$num="([0-9]|[0-9]{2}|1\d\d|2[0-4]\d|25[0-5])";
/*
[0-9] => numbers 0-9
[0-9]{2} => numbers 0-99 --> This is missing in satch666 code. It means, that if you write IP
25.213.110.1 function return FALSE!
1\d\d => numbers 100-199
2[0-4]\d => numbers 200-249
25[0-5] => numbers 250-255
*/
if (!preg_match("/^$num\.$num\.$num\.$num$/", $$ip_addr)) echo "Wrong IP
Address\n";
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51683
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51683&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51683&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51683&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51683&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51683&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51683&report=yes
Search -- http://master.php.net/manage/user-notes.php