gethostbyname

(PHP 4, PHP 5, PHP 7)

gethostbyname 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷应锟斤拷 IPv4锟斤拷址锟斤拷

说锟斤拷

gethostbyname ( string $hostname ) : string

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 hostname 锟斤拷应锟斤拷 IPv4 锟斤拷锟斤拷锟斤拷锟斤拷址锟斤拷

锟斤拷锟斤拷

hostname

锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟缴癸拷时锟斤拷锟斤拷 IPv4 锟斤拷址锟斤拷失锟斤拷时原锟解不锟斤拷锟斤拷锟斤拷 hostname 锟街凤拷锟斤拷锟斤拷

锟斤拷锟斤拷

Example #1 锟津单碉拷 gethostbyname() 锟斤拷锟斤拷

<?php
$ip 
gethostbyname('www.example.com');

echo 
$ip;
?>

锟轿硷拷

  • gethostbyaddr() - 锟斤拷取指锟斤拷锟斤拷IP锟斤拷址锟斤拷应锟斤拷锟斤拷锟斤拷锟斤拷
  • gethostbynamel() - 锟斤拷取锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷应锟斤拷 IPv4 锟斤拷址锟叫憋拷
  • inet_pton() - Converts a human readable IP address to its packed in_addr representation
  • inet_ntop() - Converts a packed internet address to a human readable representation