Home > Backend Development > PHP Tutorial > PHP函数之$_SERVER

PHP函数之$_SERVER

WBOY
Release: 2016-06-23 14:31:33
Original
1182 people have browsed it

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下也同样有效。

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template