Syntax:string inet_ntop (string $ip_address)
Parameter:This function takes one parameter as above and described below:
- $ip_address:Required. It specifies a 32-bit IPv4 or 128-bit IPv6 address.
Return Value:This function returns a string-formatted readable address on success or FALSE in in case of error.
Note.This function is available in PHP 5.1.0 and later.The following programs illustrate the inet_ntop() function in PHP:
Program 1:
// Save the address to a variable
$addr
=
chr
(127).
chr
(0).
chr
(1).
chr
(1);
// Use the inet_ntop() function to convert
// Human readable web address
// submission
$exp
= inet_ntop (
$addr
);
// Show result
echo
$exp
;
?>
Exit:127.0.1.1
Program 2:This program uses a 4-character ascii string directly in the parameter.
// Use the inet_ntop() function to convert
// Human readable web address
// presentation
echo
inet_ntop (
"[] []"
).
"
"
;
echo
inet_ntop (
"4509"
).
"
"
;
echo
inet_ntop (
"* ^ b @ "
).
"
"
;
echo
inet_ntop (
"hqp0"
).
"
"
;
echo
inet_ntop (
"2c #! "
);
?>
Exit:91.93.91.93
52.53.48.57
42.94.98.64
104.113.112.48
50.99.35.33
Link: https://www.php.net/manual/en/function.inet-ntop.php