PHP tutorial How to get Domain name IP address code function
$DM = ' www.jzread.com '; $ip = gethostbyname ($DM); echo gethostbyaddr ($IP); echo $ip;//Two output results are the same, /* About gethostbyname syntax
String gethostbyname (String $hostname)
Returns the IPv4 address of the Internet host specified by the host name Returns the IPv4 address of the Internet host specified by hostname
Here's an example of this is the best way I've proposed to address any host name to the IP address when it's fast, reliable, and has timed out support! An invalid address, such as a Unicode string, returns 4? seconds, not 8 calls to gethostbyname?! It can only be with Unix though. */
function Getaddrbyhost ($host, $timeout = 3) { $query = ' nslookup-timeout= $timeout-retry=1 $host '; if (Preg_match ('/naddress: (. *) n ', $query, $matches)) return Trim ($matches [1]); return $host; }/* GETHOSTBYADDR is to get the Internet host name for a specific IP address
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.