filter_var过滤私有ip
$host = "192.168.1.1";
var_dump(filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE));
echo "<br>";
$host = "127.0.0.1";
var_dump(filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE));
echo "<br>";
$host = "120.78.66.99";
var_dump(filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE));
echo "<br>";
$host = "172.17.2.3";
var_dump(filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE));
echo "<br>";
————————————————
bool(false)
bool(false)
string(12) "120.78.66.99"
bool(false)