WP获取访客的ip
Published
2023-01-11
浏览次数 : 146
<?php
function get_client_ip() {
$ip = $_SERVER['REMOTE_ADDR'];
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $ip;
}
echo 'Your IP address is: ' . get_client_ip();
?>
//一般性可以直接使用
<p>Your IP address is: <?php echo $_SERVER['REMOTE_ADDR']; ?></p>
- 标签1
- 标签1
- 标签1