php 获取本地IP代码
程序员文章站
2022-05-23 22:04:02
复制代码 代码如下:
<?
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();
?>