Re: about PHP's filter_var function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You can use regex to check the
format: /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
You can also explode $ip on "." and check if every part is numeric and less
than 255.


On 20 September 2012 14:44, lx <lxlenovostar@xxxxxxxxx> wrote:

> Hello:
>        I want to use filter_var function by this way:
>
>                 $ip = "192.168.0.1";
>
>                 if( !filter_var($ip, FILTER_VALIDATE_IP) )
>                 {
>                         echo "IP is not valid";
>                 }
>                 else
>                 {
>                          echo "IP is valid";
>                 }
>
> I want to check the string $ip is IP address or not.but my PHP version is
> 5.1.6.
>  and I know the filter_var requires at least PHP version 5.2.0.
> so, Any other function in PHP 5.1.6 can slove this work and replace the
> filter_var function ?
>
> Thank you, I'm a new one, so I don't know much about  PHP documentation.
>
> By the way, The PHP version is required. so I can't upgrade it.
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux