Home > Article > Backend Development > PHP函数之$_SERVER
http://a.liao1.com/sherry/auto/test.php
//获取域名或主机地址
echo $_SERVER['HTTP_HOST']."
";//a.liao1.com
//获取网页地址
echo $_SERVER['PHP_SELF']."
";//sherry/auto/test.php
//获取网址参数
//echo $_SERVER["QUERY_STRING"]."
";
//来源网页的详细地址
//echo $_SERVER['HTTP_REFERER']."
";
echo SITE_ROOT ."
";//http://a.liao1.com/sherry/auto
echo $_SERVER["SERVER_NAME"];//a.liao1.com
?>
$_SERVER["HTTP_USER_AGENT"]获取客户端浏览器的型号
函数getenv(“REMOTE_ADDR”)与$_SERVER['REMOTE_ADDR']的区别
取访客(客户端)的ip地址函数
getenv(“REMOTE_ADDR”)函数在apache下能正常获取ip地址,而在iis中,一点作用都没,
$_SERVER['REMOTE_ADDR']函数,既可在apache中成功获取访客的ip地址,在iis下也同样有效。