PHP取得使用者IP位址
<?php function getClientIp() { $uip = ''; if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_FOR'], 'unknow')) { $uip = $_SERVER['HTTP_X_FORWARDED_FOR']; strpos($uip, ',') && list($uip) = explode(',', $uip); } elseif(!empty($_SERVER['HTTP_CLIENT_IP']) && strcasecmp($_SERVER['HTTP_CLIENT_IP'], 'unknow')) { $uip = $_SERVER['HTTP_CLIENT_IP']; } elseif(!empty($_SERVER['REMOTE_ADDR']) && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknow')) { $uip = $_SERVER['REMOTE_ADDR']; } return $uip; } echo getClientIp();
以上就介紹了PHP取得使用者IP位址,包含了方面的內容,更多相關內容請追蹤PHP中文網(www.php.cn)!