Today we see several functions that can be used to obtain the corresponding domain name ip address based on the ip address domain name. This is recorded. Gethostbynamel ($ hostname) obtains the IP address based on the domain name and returns an array, such as baidu. Returns two ip addresses indicating arraygethostbynamel (string $ hostname) ReturnsalistofIPv4a
Today we can see several functions that can be used to obtain the corresponding domain name/ip address based on the ip address/domain name. This is recorded. Gethostbynamel ($ hostname) // obtain the IP address based on the domain name and return an array, such as baidu. Returns two ip addresses indicating array gethostbynamel (string $ hostname) Returns a list of IPv4
Today we can see several functions that can be used to obtain the corresponding domain name/ip address based on the ip address/domain name. This is recorded.
Gethostbynamel ($ hostname)
// AccordingDomain NameObtainIP, return an array, such as baidu. Com, two ip addresses are returned.
Description: array gethostbynamel (string $ hostname) Returns a list of IPv4 addresses to which the Internet host specified by hostname resolves. parameter hostname The host name. returned Returns an array of IPv4 addresses or FALSE if hostname cocould not be resolved.
Gethostbyname ($ hostname)// AccordingDomain NameObtainOnly the first IP address is returned.
Gethostbyname-Get the IPv4 address corresponding to a given Internet host name Description string gethostbyname (string $ hostname) Returns the IPv4 address of the Internet host specified by hostname. parameter hostname The host name. return Value Returns the IPv4 address or a string containing the unmodified hostname on failure.
Gethostbyaddr ($ ip) // obtain the domain name based on the IP address
Gethostbyaddr-Get the Internet host name corresponding to a given IP address description string gethostbyaddr (string $ ip_address) Returns the host name of the Internet host specified by ip_address. parameter ip_address The host IP address. return Value Returns the host name on success, the unmodified ip_address on failure, or FALSE on malformed input.
Example:
$hostname = 'www.baidu.com';$addr = '127.0.0.1';print_r(gethostbyname($hostname));echo '
';print_r(gethostbyaddr($addr));echo '
';print_r(gethostbynamel($hostname));
Output
220.181.111.148idc-wangArray ( [0] => 220.181.111.148 [1] => 220.181.112.143 )