的IP地址,這可能是最後一個問題我想問,我無法找到問題......所以這是我使用的代碼:我不能讓用戶
function get_client_ip() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
而且這是我用來嘗試,看看它是否拿起我的IP:
<p>IP: <?php get_client_ip(); ?> </p>
我所看到的,當我走在頁面上爲IP: 並沒有IP ... 我真的不知道爲什麼會發生這種情況...
您可以添加'的print_r($ _ SERVER);' –
您需要呼應的結果,例如'<?php echo get_client_ip(); ?>' – rjdown