note 59910 added to function.ip2long
| From: | greg at netops dot gvtc dot com | Date: | Mon, 19 Dec 2005 23:43:25 +0000 |
| Subject: | note 59910 added to function.ip2long | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100438@lists.php.net to get a copy of this message | ||
Re: m.ozarek's isIpMask() function
You might want to adjust your preg_match line from:
if(preg_match("/[0-9].[0-9].[0-9].[0-9]/",$mask)){
to
if(preg_match("/[0-9]++\.[0-9]++\.[0-9]++\.[0-9]++/",$mask)){
this should properly match up to 3 characters per octet and require that the periods be periods not
just any character. I tested against a handful of IPs, and it seemed to match fine, and did not
allow a 7 digit number to be considered a mask to check. This is probably more useful if doing a
match against a regular IP than against the subnet mask, but its always good to have more layers of
checking.
*note.. not all applications support the regex + metacharacter.
----
Manual Page -- http://www.php.net/manual/en/function.ip2long.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59910
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59910&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59910&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59910&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59910&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59910&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59910&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59910&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59910&report=yes
Search -- http://master.php.net/manage/user-notes.php