18 lines
508 B
PHP
18 lines
508 B
PHP
<?php
|
|
$ipv4 = $_SERVER['REMOTE_ADDR'];
|
|
|
|
// Get the IPv6 address of the client if available
|
|
$ipv6 = $_SERVER['REMOTE_ADDR'];
|
|
if (strpos($ipv6, ":") !== false) {
|
|
// IPv6 address detected
|
|
$ipv6 = explode("%", $ipv6)[0]; // Remove interface suffix, if any
|
|
} else {
|
|
// No IPv6 address detected
|
|
$ipv6 = "IPv6 not available";
|
|
}
|
|
|
|
// Display IPv4 and IPv6 addresses
|
|
echo "IPv4 Address: " . $ipv4 . "<br>";
|
|
echo "IPv6 Address: " . $ipv6 . "<br>";
|
|
?>
|