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

获取当前服务器地址

WBOY
Release: 2016-06-06 19:35:50
Original
868 people have browsed it

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

?>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template