PHP gethostbyaddr()函数用法介绍

2021年3月13日17:11:53 发表评论 795 次浏览

gethostbyaddr()函数是PHP中的内置函数, 它返回指定IP地址的域名

语法如下:

gethostbyaddr($ip_address);

参数:该函数接受上面提到并在下面描述的一个参数:

  • $ ip_address:必填参数。它指定要查找其主机名的IP地址。作为字符串传递。

返回值:

  • 该函数成功返回主机名, 失败返回IP地址。

注意:

  • 此功能可用于PHP 4.0.0和更高版本。

例子

<?php
$host = gethostbyaddr ( "52.25.109.230" );
echo $host ;
?>

输出如下:

ec2-52-25-109-230.us-west-2.compute.amazonaws.com

参考: https://www.php.net/manual/en/function.gethostbyaddr.php


木子山

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: