首页 > 技术文章 > $_SERVER服务器端

2018-05-9-ygk 2019-04-28 14:24 原文

url = 'http://www.5idev.com/php/index.php/test/foo?username=hbolive'

php 获取$_SERVER信息

$_SERVER['PHP_SELF'] 得到:/php/index.php/test/foo 得到当前正在执行脚本的文件名

$_SERVER['SCRIPT_NAME'] 得到:/php/index.php 包含当前脚本的路径

$_SERVER['REQUEST_URI'] 得到:/php/index.php/test/foo?username=hbolive 访问此页面所需的URI

$_SERVER['QUERY_STRING'] 得到查询字符串username=hbolive

推荐阅读