<!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>Converts a packed internet address to a human readable representation</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.http-response-code.html">http_response_code</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.inet-pton.html">inet_pton</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.inet-ntop" class="refentry"> <div class="refnamediv"> <h1 class="refname">inet_ntop</h1> <p class="verinfo">(PHP 5 >= 5.1.0)</p><p class="refpurpose"><span class="refname">inet_ntop</span> — <span class="dc-title">Converts a packed internet address to a human readable representation</span></p> </div> <div class="refsect1 description" id="refsect1-function.inet-ntop-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>inet_ntop</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$in_addr</code></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> <div class="refsect1 parameters" id="refsect1-function.inet-ntop-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">in_addr</code></em></span> <dd> <p class="para"> A 32bit IPv4, or 128bit IPv6 address. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.inet-ntop-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a string representation of the address or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.inet-ntop-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4489"> <p><strong>Example #1 <span class="function"><strong>inet_ntop()</strong></span> Example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$packed </span><span style="color: #007700">= </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">127</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">) . </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">) . </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 </span><span style="color: #007700">= </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">/* Outputs: 127.0.0.1 */<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$expanded</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$packed </span><span style="color: #007700">= </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">), </span><span style="color: #0000BB">15</span><span style="color: #007700">) . </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 </span><span style="color: #007700">= </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">/* Outputs: ::1 */<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$expanded</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 changelog" id="refsect1-function.inet-ntop-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.3.0</td> <td> This function is now available on Windows platforms. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 seealso" id="refsect1-function.inet-ntop-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.long2ip.html" class="function" rel="rdfs-seeAlso">long2ip()</a> - Converts an (IPv4) Internet network address into a string in Internet standard dotted format</span></li> <li class="member"> <span class="function"><a href="function.ip2long.html" class="function" rel="rdfs-seeAlso">ip2long()</a> - Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address</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> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.http-response-code.html">http_response_code</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.inet-pton.html">inet_pton</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>