欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php应用路径变量问题总结_PHP教程

程序员文章站 2022-05-09 14:34:38
...

本地服务器,域名http://d.com,根路径D:\phpnow\vhosts\d.com.yii,相对根目录拥有文件/x.php代码里requeir_once /a/a.php,而/a/a.php又requeir_once /a/b/b.php

/x.php


$_SERVER["HTTP_HOST"]:【d.com】//当前请求的 Host:即域名信信息

$_SERVER["PHP_SELF"]:【】//
$_SERVER["SCRIPT_NAME"]:【/x.php】//
$_SERVER["SCRIPT_FILENAME"]:【D:/phpnow/vhosts/d.com.yii/x.php】//
__FILE__ :【】//

$_SERVER["REQUEST_URI"]:【/x.php/x/y/z.html?a=b&c=d】//url请求中包括/和之后的所有内容。
$_SERVER["QUERY_STRING"]:【a=b&c=d】//url请求中?之后的内容。

$_SERVER["DOCUMENT_ROOT"]:【D:/phpnow/vhosts/d.com.yii】//文档根目录。在服务器配置文件中定义

basename($_SERVER["PHP_SELF"]):【】//
basename($_SERVER["SCRIPT_NAME"]):【x.php】//
basename($_SERVER["SCRIPT_FILENAME"]):【x.php】//
basename(__FILE__):【】//

dirname($_SERVER["PHP_SELF"]):【】//
dirname($_SERVER["SCRIPT_NAME"]):【\】//
dirname($_SERVER["SCRIPT_FILENAME"]):【D:/phpnow/vhosts/d.com.yii】//
dirname(__FILE__):【】//

require_once /a/a.php


$_SERVER["HTTP_HOST"]:【d.com】//当前请求的 Host:即域名信信息

$_SERVER["PHP_SELF"]:【】//
$_SERVER["SCRIPT_NAME"]:【/x.php】//
$_SERVER["SCRIPT_FILENAME"]:【D:/phpnow/vhosts/d.com.yii/x.php】//
__FILE__ :【】//

$_SERVER["REQUEST_URI"]:【/x.php/x/y/z.html?a=b&c=d】//url请求中包括/和之后的所有内容。
$_SERVER["QUERY_STRING"]:【a=b&c=d】//url请求中?之后的内容。

$_SERVER["DOCUMENT_ROOT"]:【D:/phpnow/vhosts/d.com.yii】//文档根目录。在服务器配置文件中定义

basename($_SERVER["PHP_SELF"]):【】//
basename($_SERVER["SCRIPT_NAME"]):【x.php】//
basename($_SERVER["SCRIPT_FILENAME"]):【x.php】//
basename(__FILE__):【】//

dirname($_SERVER["PHP_SELF"]):【】//
dirname($_SERVER["SCRIPT_NAME"]):【\】//
dirname($_SERVER["SCRIPT_FILENAME"]):【D:/phpnow/vhosts/d.com.yii】//
dirname(__FILE__):【】//

require_once /a/b/b.php


$_SERVER["HTTP_HOST"]:【d.com】//当前请求的 Host:即域名信信息

$_SERVER["PHP_SELF"]:【】//
$_SERVER["SCRIPT_NAME"]:【/x.php】//
$_SERVER["SCRIPT_FILENAME"]:【D:/phpnow/vhosts/d.com.yii/x.php】//
__FILE__ :【】//

$_SERVER["REQUEST_URI"]:【/x.php/x/y/z.html?a=b&c=d】//url请求中包括/和之后的所有内容。
$_SERVER["QUERY_STRING"]:【a=b&c=d】//url请求中?之后的内容。

$_SERVER["DOCUMENT_ROOT"]:【D:/phpnow/vhosts/d.com.yii】//文档根目录。在服务器配置文件中定义

basename($_SERVER["PHP_SELF"]):【】//
basename($_SERVER["SCRIPT_NAME"]):【x.php】//
basename($_SERVER["SCRIPT_FILENAME"]):【x.php】//
basename(__FILE__):【】//

dirname($_SERVER["PHP_SELF"]):【】//
dirname($_SERVER["SCRIPT_NAME"]):【\】//
dirname($_SERVER["SCRIPT_FILENAME"]):【D:/phpnow/vhosts/d.com.yii】//
dirname(__FILE__):【】//

/a/a.php


$_SERVER["HTTP_HOST"]:【d.com】//当前请求的 Host:即域名信信息

$_SERVER["PHP_SELF"]:【】//
$_SERVER["SCRIPT_NAME"]:【/a/a.php】//
$_SERVER["SCRIPT_FILENAME"]:【D:/phpnow/vhosts/d.com.yii/a/a.php】//
__FILE__ :【】//

$_SERVER["REQUEST_URI"]:【/a/a.php/x/y/z.html?a=b&c=d】//url请求中包括/和之后的所有内容。
$_SERVER["QUERY_STRING"]:【a=b&c=d】//url请求中?之后的内容。

$_SERVER["DOCUMENT_ROOT"]:【D:/phpnow/vhosts/d.com.yii】//文档根目录。在服务器配置文件中定义

basename($_SERVER["PHP_SELF"]):【】//
basename($_SERVER["SCRIPT_NAME"]):【a.php】//
basename($_SERVER["SCRIPT_FILENAME"]):【a.php】//
basename(__FILE__):【】//

dirname($_SERVER["PHP_SELF"]):【】//
dirname($_SERVER["SCRIPT_NAME"]):【/a】//
dirname($_SERVER["SCRIPT_FILENAME"]):【D:/phpnow/vhosts/d.com.yii/a】//
dirname(__FILE__):【】//

require_once /a/b/b.php


$_SERVER["HTTP_HOST"]:【d.com】//当前请求的 Host:即域名信信息

$_SERVER["PHP_SELF"]:【】//
$_SERVER["SCRIPT_NAME"]:【/a/a.php】//
$_SERVER["SCRIPT_FILENAME"]:【D:/phpnow/vhosts/d.com.yii/a/a.php】//
__FILE__ :【】//

$_SERVER["REQUEST_URI"]:【/a/a.php/x/y/z.html?a=b&c=d】//url请求中包括/和之后的所有内容。
$_SERVER["QUERY_STRING"]:【a=b&c=d】//url请求中?之后的内容。

$_SERVER["DOCUMENT_ROOT"]:【D:/phpnow/vhosts/d.com.yii】//文档根目录。在服务器配置文件中定义

basename($_SERVER["PHP_SELF"]):【】//
basename($_SERVER["SCRIPT_NAME"]):【a.php】//
basename($_SERVER["SCRIPT_FILENAME"]):【a.php】//
basename(__FILE__):【】//

dirname($_SERVER["PHP_SELF"]):【】//
dirname($_SERVER["SCRIPT_NAME"]):【/a】//
dirname($_SERVER["SCRIPT_FILENAME"]):【D:/phpnow/vhosts/d.com.yii/a】//
dirname(__FILE__):【】//

/x.php

 "
/x.php
" '$_SERVER["HTTP_HOST"]:【',['HTTP_HOST'],"】//当前请求的 Host:即域名信信息","
" '
' '$_SERVER["PHP_SELF"]:【',['PHP_SELF'],"】//请求执行文件的相对地址","
" '$_SERVER["SCRIPT_NAME"]:【',['SCRIPT_NAME'],"】//实际执行文件相对地址","
" '$_SERVER["SCRIPT_FILENAME"]:【',['SCRIPT_FILENAME'],"】//实际执行文件的绝对路径。","
" '__FILE__ :【', ,"】//实际执行代码的绝对路径。","
" '
' '$_SERVER["REQUEST_URI"]:【',['REQUEST_URI'],"】//url请求中包括/和之后的所有内容。","
" '$_SERVER["QUERY_STRING"]:【',['QUERY_STRING'],"】//url请求中?之后的内容。","
" '
' '$_SERVER["DOCUMENT_ROOT"]:【',['DOCUMENT_ROOT'],"】//文档根目录。在服务器配置文件中定义","
" "
" 'basename($_SERVER["PHP_SELF"]):【',(['PHP_SELF']),"】//请求执行文件的文件名","
" 'basename($_SERVER["SCRIPT_NAME"]):【',(['SCRIPT_NAME']),"】//实际执行文件文件名","
" 'basename($_SERVER["SCRIPT_FILENAME"]):【',(['SCRIPT_FILENAME']),"】//实际执行文件文件名","
" 'basename(__FILE__):【',(),"】//实际执行代码文件名","
""; "
" 'dirname($_SERVER["PHP_SELF"]):【',(['PHP_SELF']),"】//请求执行文件的所在目录","
" 'dirname($_SERVER["SCRIPT_NAME"]):【',(['SCRIPT_NAME']),"】//实际执行文件所在目录","
" 'dirname($_SERVER["SCRIPT_FILENAME"]):【',(['SCRIPT_FILENAME']),"】//实际执行文件所在目录","
" 'dirname(__FILE__):【',(),"】//实际执行代码所在目录","
""; "
" "require_once "("a/a.php");

/a/a.php

 "/a/a.php
" '$_SERVER["HTTP_HOST"]:【',['HTTP_HOST'],"】//当前请求的 Host:即域名信信息","
" '
' '$_SERVER["PHP_SELF"]:【',['PHP_SELF'],"】//请求执行文件的相对地址","
" '$_SERVER["SCRIPT_NAME"]:【',['SCRIPT_NAME'],"】//实际执行文件相对地址","
" '$_SERVER["SCRIPT_FILENAME"]:【',['SCRIPT_FILENAME'],"】//实际执行文件的绝对路径。","
" '__FILE__ :【', ,"】//实际执行代码的绝对路径。","
" '
' '$_SERVER["REQUEST_URI"]:【',['REQUEST_URI'],"】//url请求中包括/和之后的所有内容。","
" '$_SERVER["QUERY_STRING"]:【',['QUERY_STRING'],"】//url请求中?之后的内容。","
" '
' '$_SERVER["DOCUMENT_ROOT"]:【',['DOCUMENT_ROOT'],"】//文档根目录。在服务器配置文件中定义","
" "
" 'basename($_SERVER["PHP_SELF"]):【',(['PHP_SELF']),"】//请求执行文件的文件名","
" 'basename($_SERVER["SCRIPT_NAME"]):【',(['SCRIPT_NAME']),"】//实际执行文件文件名","
" 'basename($_SERVER["SCRIPT_FILENAME"]):【',(['SCRIPT_FILENAME']),"】//实际执行文件文件名","
" 'basename(__FILE__):【',(),"】//实际执行代码文件名","
""; "
" 'dirname($_SERVER["PHP_SELF"]):【',(['PHP_SELF']),"】//请求执行文件的所在目录","
" 'dirname($_SERVER["SCRIPT_NAME"]):【',(['SCRIPT_NAME']),"】//实际执行文件所在目录","
" 'dirname($_SERVER["SCRIPT_FILENAME"]):【',(['SCRIPT_FILENAME']),"】//实际执行文件所在目录","
" 'dirname(__FILE__):【',(),"】//实际执行代码所在目录","
""; "
" "require_once "("b/b.php");

/a/b/php

 "/a/b/b.php
" '$_SERVER["HTTP_HOST"]:【',['HTTP_HOST'],"】//当前请求的 Host:即域名信信息","
" '
' '$_SERVER["PHP_SELF"]:【',['PHP_SELF'],"】//请求执行文件的相对地址","
" '$_SERVER["SCRIPT_NAME"]:【',['SCRIPT_NAME'],"】//实际执行文件相对地址","
" '$_SERVER["SCRIPT_FILENAME"]:【',['SCRIPT_FILENAME'],"】//实际执行文件的绝对路径。","
" '__FILE__ :【', ,"】//实际执行代码的绝对路径。","
" '
' '$_SERVER["REQUEST_URI"]:【',['REQUEST_URI'],"】//url请求中包括/和之后的所有内容。","
" '$_SERVER["QUERY_STRING"]:【',['QUERY_STRING'],"】//url请求中?之后的内容。","
" '
' '$_SERVER["DOCUMENT_ROOT"]:【',['DOCUMENT_ROOT'],"】//文档根目录。在服务器配置文件中定义","
" "
" 'basename($_SERVER["PHP_SELF"]):【',(['PHP_SELF']),"】//请求执行文件的文件名","
" 'basename($_SERVER["SCRIPT_NAME"]):【',(['SCRIPT_NAME']),"】//实际执行文件文件名","
" 'basename($_SERVER["SCRIPT_FILENAME"]):【',(['SCRIPT_FILENAME']),"】//实际执行文件文件名","
" 'basename(__FILE__):【',(),"】//实际执行代码文件名","
""; "
" 'dirname($_SERVER["PHP_SELF"]):【',(['PHP_SELF']),"】//请求执行文件的所在目录","
" 'dirname($_SERVER["SCRIPT_NAME"]):【',(['SCRIPT_NAME']),"】//实际执行文件所在目录","
" 'dirname($_SERVER["SCRIPT_FILENAME"]):【',(['SCRIPT_FILENAME']),"】//实际执行文件所在目录","
" 'dirname(__FILE__):【',(),"】//实际执行代码所在目录","
""; "
";

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440233.htmlTechArticle本地服务器,域名http://d.com,根路径 D:\phpnow\vhosts\d.com.yii,相对根目录拥有文件/x.php代码里requeir_once /a/a.php,而/a/a.php又requeir_once/a/b/b.php...