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
String gethostbyaddr (String $ip _address) */
$hostname = gethostbyaddr ($_server[' remote_addr '));
Echo $hostname;
Original website Reprint www.jzread.com