Re: [PHP] IPv6 validation



Doesnt filter_var() require PHP5+ ?

I have quite some systems still running 4.4.8.

On 7/12/08, Kevin Waterson <kevin@xxxxxxxxx> wrote:

This one time, at band camp, Yeti <yeti@xxxxxxxxxx> wrote:

Now i was wondering of what there might be the best way to validate an
IPv6
address.


from this url..
http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9

<?php

/*** an IP address ***/
$ip = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334";

/*** try to validate as IPV6 address ***/
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
{
echo "$ip is not a valid IP";
}
else
{
echo "$ip is valid";
}
?>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Relevant Pages

  • Re: [PHP] IPv6 validation
    ... an IPv6 address. ... echo "$ip is not a valid IP"; ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] IPv6 validation
    ... This one time, at band camp, Yeti wrote: ... IPv6 ... echo "$ip is not a valid IP"; ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] IPv6 validation
    ... echo "$ip is not a valid IP"; ... PHP General Mailing List ... I installed php5 on my local dev box years ago. ... my company to upgrade and fix code that busted in the transition. ...
    (php.general)
  • Re: [PHP] Bind IP with fsockopen
    ... echo $sock; //output reply?? ... >> I think im getting stuck on the fputs bit.. ... >> PHP General Mailing List ... >> To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • mysql if empty
    ... If I search for something in mysql that returns an empty result I cant get it to return ... echo "No result found"; ... PHP General Mailing List ...
    (php.general)