php 获取本地IP代码
程序员文章站
2023-01-13 10:31:31
复制代码 代码如下:
<?
function get_client_ip()
{
if ($_server['remote_addr']) {
$cip = $_server['remote_addr'];
} elseif (getenv("remote_addr")) {
$cip = getenv("remote_addr");
} elseif (getenv("http_client_ip")) {
$cip = getenv("http_client_ip");
} else {
$cip = "unknown";
}
return $cip;
}
echo "你的ip地址是:".get_client_ip();
?>
复制代码 代码如下:
<?
function get_client_ip()
{
if ($_server['remote_addr']) {
$cip = $_server['remote_addr'];
} elseif (getenv("remote_addr")) {
$cip = getenv("remote_addr");
} elseif (getenv("http_client_ip")) {
$cip = getenv("http_client_ip");
} else {
$cip = "unknown";
}
return $cip;
}
echo "你的ip地址是:".get_client_ip();
?>
上一篇: 哥教训弟弟老师冷站