<!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 human readable IP address to its packed in_addr representation</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.inet-ntop.html">inet_ntop</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ip2long.html">ip2long</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-pton" class="refentry"> <div class="refnamediv"> <h1 class="refname">inet_pton</h1> <p class="verinfo">(PHP 5 >= 5.1.0)</p><p class="refpurpose"><span class="refname">inet_pton</span> — <span class="dc-title">Converts a human readable IP address to its packed in_addr representation</span></p> </div> <div class="refsect1 description" id="refsect1-function.inet-pton-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>inet_pton</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$address</code></span> )</div> <p class="para rdfs-comment"> This function converts a human readable IPv4 or IPv6 address (if PHP was built with IPv6 support enabled) into an address family appropriate 32bit or 128bit binary structure. </p> </div> <div class="refsect1 parameters" id="refsect1-function.inet-pton-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">address</code></em></span> <dd> <p class="para"> A human readable IPv4 or IPv6 address. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.inet-pton-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the <em>in_addr</em> representation of the given <em><code class="parameter">address</code></em>, or <strong><code>FALSE</code></strong> if a syntactically invalid <em><code class="parameter">address</code></em> is given (for example, an IPv4 address without dots or an IPv6 address without colons). </p> </div> <div class="refsect1 examples" id="refsect1-function.inet-pton-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4490"> <p><strong>Example #1 <span class="function"><strong>inet_pton()</strong></span> Example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$in_addr </span><span style="color: #007700">= </span><span style="color: #0000BB">inet_pton</span><span style="color: #007700">(</span><span style="color: #DD0000">'127.0.0.1'</span><span style="color: #007700">);<br /> <br /></span><span style="color: #0000BB">$in6_addr </span><span style="color: #007700">= </span><span style="color: #0000BB">inet_pton</span><span style="color: #007700">(</span><span style="color: #DD0000">'::1'</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-pton-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-pton-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <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.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.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.inet-ntop.html">inet_ntop</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ip2long.html">ip2long</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>