downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.inet-ntop.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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.inet-ntop.php',
   
1 => 'inet_ntop',
  ),
 
'up' =>
  array (
   
0 => 'ref.network.php',
   
1 => 'Network Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.headers-sent.php',
   
1 => 'headers_sent',
  ),
 
'next' =>
  array (
   
0 => 'function.inet-pton.php',
   
1 => 'inet_pton',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.inet-ntop" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">inet_ntop</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">inet_ntop</span> &mdash; <span class="dc-title">Converts a packed internet address to a human readable representation</span></p>

 </div>
 
 <a name="function.inet-ntop.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><b>inet_ntop</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$in_addr</tt></span>
   )</div>

  <p class="simpara">
   This function converts a 32bit IPv4, or 128bit IPv6 address (if PHP
   was built with IPv6 support enabled) into an address family appropriate
   string representation. 
  </p>
 </div>


 <a name="function.inet-ntop.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">in_addr</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       A 32bit IPv4, or 128bit IPv6 address.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.inet-ntop.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a string representation of the address or <b><tt class="constant">FALSE</tt></b> on failure.
  </p>
 </div>


 <a name="function.inet-ntop.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>inet_ntop()</b> Example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$packed&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">127</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$expanded&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">inet_ntop</span><span style="color: #007700">(</span><span style="color: #0000BB">$packed</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Outputs:&nbsp;127.0.0.1&nbsp;*/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$expanded</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$packed&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">str_repeat</span><span style="color: #007700">(</span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">15</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$expanded&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">inet_ntop</span><span style="color: #007700">(</span><span style="color: #0000BB">$packed</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Outputs:&nbsp;::1&nbsp;*/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$expanded</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.inet-ntop.changelog"></a><div class="refsect1 changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">5.3.0</td>
       <td align="left">
         This function is now available on Windows platforms.
       </td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div>


 <a name="function.inet-ntop.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.long2ip.php" class="function" rel="rdfs-seeAlso">long2ip()</a> - Converts an (IPv4) Internet network address into a string in Internet standard dotted format</li>
    <li class="member"><a href="function.ip2long.php" class="function" rel="rdfs-seeAlso">ip2long()</a> - Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address</li>
    <li class="member"><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</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites