September 2001
Intermediate to advanced
768 pages
32h 45m
English
string gethostbyname(string hostname) Gets the IP address for an Internet host.
Returns:
IP address; the hostname argument on error
Description:
gethostbyname() performs a DNS lookup of an Internet hostname and returns the corresponding IP address. If no IP address can be found for the specified hostname, the function returns the hostname argument.
Availability:
UNIX, Windows
Version:
3+, 4+
See also:
gethostbyaddr() gethostbynamel()
Example:
<?php
$host = 'www.gnu.org';
$ip = gethostbyname ($host);
if ($ip != $host)
echo "The IP address for <i>$host</i> is <i>$ip</i>.";
else
echo "I could not successfully look up <i>$host</i>.";
?>
|
Read now
Unlock full access