<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Get the IPv4 address corresponding to a given Internet host name</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.gethostbyaddr.html">gethostbyaddr</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gethostbynamel.html">gethostbynamel</a></div> <div class="up"><a href="ref.network.html">Network Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.gethostbyname" class="refentry"> <div class="refnamediv"> <h1 class="refname">gethostbyname</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">gethostbyname</span> — <span class="dc-title"> Get the IPv4 address corresponding to a given Internet host name </span></p> </div> <div class="refsect1 description" id="refsect1-function.gethostbyname-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>gethostbyname</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$hostname</code></span> )</div> <p class="para rdfs-comment"> Returns the IPv4 address of the Internet host specified by <em><code class="parameter">hostname</code></em>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.gethostbyname-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">hostname</code></em></span> <dd> <p class="para"> The host name. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.gethostbyname-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the IPv4 address or a string containing the unmodified <em><code class="parameter">hostname</code></em> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.gethostbyname-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4476"> <p><strong>Example #1 A simple <span class="function"><strong>gethostbyname()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$ip </span><span style="color: #007700">= </span><span style="color: #0000BB">gethostbyname</span><span style="color: #007700">(</span><span style="color: #DD0000">'www.example.com'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$ip</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.gethostbyname-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.gethostbyaddr.html" class="function" rel="rdfs-seeAlso">gethostbyaddr()</a> - Get the Internet host name corresponding to a given IP address</span></li> <li class="member"> <span class="function"><a href="function.gethostbynamel.html" class="function" rel="rdfs-seeAlso">gethostbynamel()</a> - Get a list of IPv4 addresses corresponding to a given Internet host name</span></li> <li class="member"> <span class="function"><a href="function.inet-pton.html" class="function" rel="rdfs-seeAlso">inet_pton()</a> - Converts a human readable IP address to its packed in_addr representation</span></li> <li class="member"> <span class="function"><a href="function.inet-ntop.html" class="function" rel="rdfs-seeAlso">inet_ntop()</a> - Converts a packed internet address to a human readable representation</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.gethostbyaddr.html">gethostbyaddr</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gethostbynamel.html">gethostbynamel</a></div> <div class="up"><a href="ref.network.html">Network Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>