Home >Backend Development >PHP Tutorial >php几个预定义变量$_SERVER用法小结_PHP

php几个预定义变量$_SERVER用法小结_PHP

WBOY
WBOYOriginal
2016-05-31 19:28:14818browse

本文实例总结了php几个预定义变量$_SERVER的用法。分享给大家供大家参考。具体如下:

代码如下:

echo 'documentroot:'.$_SERVER['DOCUMENT_ROOT'].'
'; //根目录,在apache的配置文件里定义:httpd.conf 比如:DocumentRoot "D:/work/php_root"
echo 'httphost:'.$_SERVER['HTTP_HOST'].'
'; //域名,比如:localhost
echo 'phpself:'.$_SERVER['PHP_SELF'].'
';   // 从根目录到文件本身的路径
echo 'script filename'.$_SERVER['SCRIPT_FILENAME'].'
'; //documentroot+phpself
echo 'request uri'.$_SERVER['REQUEST_URI'].'
'; //从根目录开始所有的URL字符串,包括问号之后的字符
echo 'request method:'.$_SERVER['REQUEST_METHOD'].'
'; //请求的方法
echo 'name:'.$_REQUEST['name'].'
'; //请求参数的值
?>

希望本文所述对大家的PHP程序设计有所帮助。

Statement:
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