/**
* Get the visitor’s client IP address
*/
echo $ip = getIP();
function getIP() {
if ($_SERVER['HTTP_X_FORWARDED_FOR']){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}elseif ($_SERVER['HTTP_CLIENT_IP']){
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif ($_SERVER['REMOTE_ADDR']){
$ip = $_SERVER['REMOTE_ADDR'];
}elseif (getenv('HTTP_X_FORWARDED_FOR')){
$ip = getenv('HTTP_X_FORWARDED_FOR');
}elseif (getenv('HTTP_CLIENT_IP')){
$ip = getenv('HTTP_CLIENT_IP');
}elseif (getenv ('REMOTE_ADDR')){
$ip = getenv('REMOTE_ADDR');
}else{
$ip = '';
The above introduces how to obtain the visitor's client IP address, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.