📜  PHP |获取客户端 ip - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:08.645000             🧑  作者: Mango

代码示例1
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}