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-pton.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-pton.php',
1 => 'inet_pton',
),
'up' =>
array (
0 => 'ref.network.php',
1 => 'Network Functions',
),
'prev' =>
array (
0 => 'function.inet-ntop.php',
1 => 'inet_ntop',
),
'next' =>
array (
0 => 'function.ip2long.php',
1 => 'ip2long',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<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>
<a name="function.inet-pton.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_pton</b></span>
( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$address</tt></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>
<a name="function.inet-pton.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">address</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
A human readable IPv4 or IPv6 address.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.inet-pton.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns the <i>in_addr</i> representation of the given
<i><tt class="parameter">address</tt></i>
</p>
</div>
<a name="function.inet-pton.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
</p><div class="example">
<p><b>Example #1 <b>inet_pton()</b> Example</b></p>
<div class="example-contents programlisting">
<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>
</p>
</div>
<a name="function.inet-pton.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-pton.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.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.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.inet-ntop.php" class="function" rel="rdfs-seeAlso">inet_ntop()</a> - Converts a packed internet address to a human readable representation</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>