<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.network.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.gethostbyname.php',
    1 => 'gethostbyname',
    2 => 'Get the IPv4 address corresponding to a given Internet host name',
  ),
  'up' => 
  array (
    0 => 'ref.network.php',
    1 => 'Network Functions',
  ),
  'prev' => 
  array (
    0 => 'function.gethostbyaddr.php',
    1 => 'gethostbyaddr',
  ),
  'next' => 
  array (
    0 => 'function.gethostbynamel.php',
    1 => 'gethostbynamel',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/network/functions/gethostbyname.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.gethostbyname" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gethostbyname</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gethostbyname</span> &mdash; <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="methodname"><strong>gethostbyname</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$hostname</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Returns the IPv4 address of the Internet host specified by
   <code class="parameter">hostname</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.gethostbyname-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">hostname</code></dt>
     <dd>
      <p class="para">
       The host name.
      </p>
     </dd>
    
   </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
   <code class="parameter">hostname</code> 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-1">
    <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">&lt;?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">?&gt;</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><span class="function"><a href="function.gethostbyaddr.php" class="function" rel="rdfs-seeAlso">gethostbyaddr()</a> - Get the Internet host name corresponding to a given IP address</span></li>
    <li><span class="function"><a href="function.gethostbynamel.php" class="function" rel="rdfs-seeAlso">gethostbynamel()</a> - Get a list of IPv4 addresses corresponding to a given Internet host
   name</span></li>
    <li><span class="function"><a href="function.inet-pton.php" class="function" rel="rdfs-seeAlso">inet_pton()</a> - Converts a human readable IP address to its packed in_addr representation</span></li>
    <li><span class="function"><a href="function.inet-ntop.php" class="function" rel="rdfs-seeAlso">inet_ntop()</a> - Converts a packed internet address to a human readable representation</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>