FILTER_VALIDATE_IP 过滤器把值作为 IP 进行验证。
可能的标志:
<?php
$ip = "192.168.0.1";
if(!filter_var($ip, FILTER_VALIDATE_IP
))
{
echo "IP is not valid";
}
else
{
echo "IP is valid";
}
?>
输出:
IP is valid
<?php
$ip = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334";
if(!filter_var($ip, FILTER_VALIDATE_IP
, FILTER_FLAG_IPV6))
{
echo "IP is not valid";
}
else
{
echo "IP is valid";
}
?>
输出:
IP is valid
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号