Syntax:string inet_pton (string $ip_address)
Parameters:This function takes one parameter as above and described below:
- $ip_address:Required. Specifies a readable IP address.
Return Value:This function returns a packed 32-bit IPv4 or 128-bit IPv6 address on success and FALSE on failure .
Notes : - This function is available for PHP 5.1.0 and above.
- Output of the following examples the actual output may differ on this page. So please see the output screenshots.
The following programs illustrate the inet_pton() function in PHP:
Program 1:
// Use the inet_pton() function for IP
// address and get the result
$addr
= inet_pton (
"127.0.1.1"
);
echo
$addr
;
?>
Output: Program 2:
echo
inet_pton (
""
.
gethostbyname
(
"www.google.com"
) ).
"
"
;
echo
inet_pton (
""
.
gethostbyname
(
" www.youtube.com "
)).
"
"
;
echo
inet_pton (
""
.
gethostbyname
(
" www.facebook.com "
)).
"
"
;
echo
inet_pton (
""
.
gethostbyname
(
" www.engineerforengineer.org "
)).
"
"
;
echo
inet_pton (
""
.
gethostbyname
(
" php.net "
)).
"
"
;
?>
Output: Link: https://www.php.net/manual/en/function.inet-pton.php