获取ip程序如下:
但是$port=80端口必须打开了。如果没有,就指向一个打开的端口。
$addr = my_ip();
echo "my ip address is $addr\n";
function my_ip($dest='64.0.0.0', $port=80)
{
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_connect($socket, $dest, $port);
socket_getsockname($socket, $addr, $port);
socket_close($socket);
return $addr;
}
?>;
阅读(855) | 评论(0) | 转发(0) |