PHP inet_pton() Function

❮ PHP Network Reference

Example

Convert a readable IP address into a packed format:

<?php
$addr = inet_pton("127.0.1.1");
echo $addr;
?>


Definition and Usage

The inet_pton() function converts a readable IP address into a packed 32bit IPv4 or 128bit IPv6 format.

Syntax

inet_pton(address)

Parameter Values

Parameter Description
address Required. Specifies a readable IP address

Technical Details

Return Value: The address as a packed 32bit IPv4 or 128bit IPv6 format. FALSE on failure
PHP Version: 5.1+
PHP Changelog: PHP 5.3: Now available on Windows platforms

❮ PHP Network Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.