A simple function in php to verify IPV4 Address. It is completely based in regex and does full ip verifying.
It tests the ip for;
1. Need 4 numeric blocks separated by a dot.
2. Each numeric block must noot exceed 255.
3. Shouldn’t contain space. So remember to trim before calling this function.
function isINetAddress($ipaddr){ if( preg_match( "/^((?: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])$/m",$ipaddr) > 0) return true; }
This can’t me more simpler. ![]()
Enjoy!
August 26, 2010 at 13:22
function isINetAddress($ipaddr){
return (boolean)preg_match( “/^((?: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])$/m”,$ipaddr);
}
de ce nu a?a? plus dac? nu coincide returneaz? false în loc de null..
August 27, 2010 at 12:36
Merge ?i a?a