Aug 052011
Validate IP address in PHP
Answer:
If you are using PHP 5.2 or above (in fact, at the moment of writing, you should use at least PHP 5.3+), you can use the following easy method:
if(filter_var($ip, FILTER_VALIDATE_IP))
{
// Valid IP
}
else
{
// Invalid IP
}