Home > php教程 > php手册 > php使用$_SERVER["REMOTE_ADDR"]获取访问IP地址,_serverremote_addr

php使用$_SERVER["REMOTE_ADDR"]获取访问IP地址,_serverremote_addr

WBOY
Release: 2016-06-13 09:06:10
Original
1151 people have browsed it

php使用$_SERVER["REMOTE_ADDR"]获取访问IP地址,_serverremote_addr



print "您的IP地址是:";


if(!empty($_SERVER["HTTP_CLIENT_IP"])){
  $cip = $_SERVER["HTTP_CLIENT_IP"];
}
elseif(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
  $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif(!empty($_SERVER["REMOTE_ADDR"])){
  $cip = $_SERVER["REMOTE_ADDR"];
}
else{
  $cip = "无法获取!";
}
print $cip;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template