首页 >php教程 >php手册 >获取当前服务器地址

获取当前服务器地址

WBOY
WBOY原创
2016-06-06 19:35:50871浏览

获取当期的服务器地址 无 ?php $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($so

获取当期的服务器地址
<?php 
  $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;
  }

?>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn