Home > Backend Development > PHP Tutorial > Summary of PHP application path variable problems_PHP tutorial

Summary of PHP application path variable problems_PHP tutorial

WBOY
Release: 2016-07-20 11:15:03
Original
842 people have browsed it

Local server, domain name http://d.com, root path D:phpnowvhostsd.com.yii, the relative root directory has the file /x.php in the code requeir_once /a/a.php, and /a /a.phprequeir_once /a/b/b.php

/x.php


$_SERVER["HTTP_HOST"]: [d.com]//Host currently requested: domain name information

$_SERVER["PHP_SELF"]: [】//
$_SERVER["SCRIPT_NAME"]:【/x.php】 //
$_SERVER["SCRIPT_FILENAME"]: [D:/phpnow/vhosts/d.com.yii/x.php 】// of the actual execution file.
__FILE__: []// of the actual execution code.

$_SERVER["REQUEST_URI"]: [/x.php/x/y/z.html?a=b&c=d]//The url request includes all content after / and after.
$_SERVER["QUERY_STRING"]: [a=b&c=d] //The content after ? in the url request.

$_SERVER["DOCUMENT_ROOT"]: [D:/phpnow/vhosts/d.com.yii]//Document root directory. Define

basename($_SERVER["PHP_SELF"]) in the server configuration file: []// to execute the file 🎜>basename($_SERVER["SCRIPT_NAME"]): [x.php] //basename($_SERVER["SCRIPT_FILENAME" ]): [x.php]//’s basename(__FILE__): []//'s
dirname($_SERVER["PHP_SELF"]): []//'s dirname($_SERVER["SCRIPT_NAME"]): []//'s dirname($_SERVER["SCRIPT_FILENAME"]): [D:/phpnow/vhosts/d.com.yii]// is located dirname(__FILE__) : []//'s
require_once /a/a.php


$_SERVER["HTTP_HOST"]: [d.com]//Host currently requested: domain name information


$_SERVER["PHP_SELF"]: [】//$_SERVER["SCRIPT_NAME"]:【/x.php】 //$_SERVER["SCRIPT_FILENAME"]: [D:/phpnow/vhosts/d.com.yii/x.php 】// of the actual execution file. __FILE__: []// of the actual execution code.
$_SERVER["REQUEST_URI"]: [/x.php/x/y/z.html?a=b&c=d]//The url request includes all content after / and after.
$_SERVER["QUERY_STRING"]: [a=b&c=d] //The content after ? in the url request.

$_SERVER["DOCUMENT_ROOT"]: [D:/phpnow/vhosts/d.com.yii]//Document root directory. Define

basename($_SERVER["PHP_SELF"]) in the server configuration file: []// to execute the file 🎜>basename($_SERVER["SCRIPT_NAME"]): [x.php] //
basename($_SERVER["SCRIPT_FILENAME" ]): [x.php]//’s basename(__FILE__): []//'s dirname($_SERVER["PHP_SELF"]): []//'s dirname($_SERVER["SCRIPT_NAME"]): []//'s dirname($_SERVER["SCRIPT_FILENAME"]): [D:/phpnow/vhosts/d.com.yii]// is located
dirname(__FILE__) :[]//'s require_once /a/b/b.php


$_SERVER["HTTP_HOST"]: [d.com]//Host currently requested: domain name information

$_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]//The url request includes all content after / and after.
$_SERVER["QUERY_STRING"]: [a=b&c=d] //The content after ? in the url request.

$_SERVER["DOCUMENT_ROOT"]: [D:/phpnow/vhosts/d.com.yii]//Document root directory. Define

basename($_SERVER["PHP_SELF"]) in the server configuration file: []//'s
basename($_SERVER["SCRIPT_NAME"]) :[x.php]//'s
basename($_SERVER["SCRIPT_FILENAME"]): [x.php]//'s
basename(__FILE__) :【】//'s

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

/a/a.php


$_SERVER["HTTP_HOST"]: [d.com]//Host currently requested: domain name information

$_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]//The url request includes / and everything after it.
$_SERVER["QUERY_STRING"]: [a=b&c=d] //The content after ? in the url request.

$_SERVER["DOCUMENT_ROOT"]: [D:/phpnow/vhosts/d.com.yii]//Document root directory. Define

basename($_SERVER["PHP_SELF"]) in the server configuration file: []//'s
basename($_SERVER["SCRIPT_NAME"]) :[a.php]//’s
basename($_SERVER["SCRIPT_FILENAME"]): [a.php]//’s
basename(__FILE__) :【】//'s

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

require_once /a/b/b.php


$_SERVER["HTTP_HOST"]: [d.com]//Host currently requested: domain name information

$_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]//The url request includes / and everything after it.
$_SERVER["QUERY_STRING"]: [a=b&c=d] //The content after ? in the url request.

$_SERVER["DOCUMENT_ROOT"]: [D:/phpnow/vhosts/d.com.yii]//Document root directory. Define

basename($_SERVER["PHP_SELF"]) in the server configuration file: []//'s
basename($_SERVER["SCRIPT_NAME"]) :[a.php]//’s
basename($_SERVER["SCRIPT_FILENAME"]): [a.php]//’s
basename(__FILE__) :【】//'s

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

/x.php

<?<span php
</span><span echo</span> "<br/>/x.php<hr/>"<span ;

</span><span echo</span> '$_SERVER["HTTP_HOST"]:【',<span $_SERVER</span>['HTTP_HOST'],"】//当前请求的 Host:即域名信信息","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["PHP_SELF"]:【<font color="#EE00EE">',<span $_SERVER</span>['PHP_SELF'],"</font>】//<font color='green'>请求执行文件的</font><font color='red'>相对</font><font color='blue'>地址</font>","<br/>"<span ;
</span><span echo</span> '$_SERVER["SCRIPT_NAME"]:【',<span $_SERVER</span>['SCRIPT_NAME'],"】//<font color='green'>实际执行文件</font><font color='red'>相对</font><font color='blue'>地址</font>","<br/>"<span ;
</span><span echo</span> '$_SERVER["SCRIPT_FILENAME"]:【',<span $_SERVER</span>['SCRIPT_FILENAME'],"】//<font color='green'>实际执行文件的</font><font color='red'>绝对</font><font color='blue'>路径</font>。","<br/>"<span ;
</span><span echo</span> '__FILE__ :【<font color="#EE00EE">',<span __FILE__</span> ,"</font>】//<font color='green'>实际执行代码的</font><font color='red'>绝对</font><font color='blue'>路径</font>。","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["REQUEST_URI"]:【',<span $_SERVER</span>['REQUEST_URI'],"】//url请求中包括/和之后的所有内容。","<br/>"<span ;
</span><span echo</span> '$_SERVER["QUERY_STRING"]:【',<span $_SERVER</span>['QUERY_STRING'],"】//url请求中?之后的内容。","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["DOCUMENT_ROOT"]:【',<span $_SERVER</span>['DOCUMENT_ROOT'],"】//文档根目录。在服务器配置文件中定义","<br/>"<span ;
</span><span echo</span> "<br/>"<span ;


</span><span echo</span> 'basename($_SERVER["PHP_SELF"]):【<font color="#EE00EE">',<span basename</span>(<span $_SERVER</span>['PHP_SELF']),"</font>】//<font color='green'>请求执行文件的</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename($_SERVER["SCRIPT_NAME"]):【',<span basename</span>(<span $_SERVER</span>['SCRIPT_NAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename($_SERVER["SCRIPT_FILENAME"]):【',<span basename</span>(<span $_SERVER</span>['SCRIPT_FILENAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename(__FILE__):【<font color="#EE00EE">',<span basename</span>(<span __FILE__</span>),"</font>】//<font color='green'>实际执行代码</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span //</span><span echo 'basename($_SERVER["ORIG_SCRIPT_NAME"]):【',basename($_SERVER['ORIG_SCRIPT_NAME']),"】//如果PHP通过CGI来运行,这个变量的值就是/Php/Php.exe 如果Apache将PHP脚本作为模块来运行,该变量的值应该是/Phptest.php","<br/>";</span>
<span echo</span> "<br/>"<span ;


</span><span echo</span> 'dirname($_SERVER["PHP_SELF"]):【<font color="#EE00EE">',<span dirname</span>(<span $_SERVER</span>['PHP_SELF']),"</font>】//<font color='green'>请求执行文件的</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname($_SERVER["SCRIPT_NAME"]):【',<span dirname</span>(<span $_SERVER</span>['SCRIPT_NAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname($_SERVER["SCRIPT_FILENAME"]):【',<span dirname</span>(<span $_SERVER</span>['SCRIPT_FILENAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname(__FILE__):【<font color="#EE00EE">',<span dirname</span>(<span __FILE__</span>),"</font>】//<font color='green'>实际执行代码</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span //</span><span echo 'dirname($_SERVER["ORIG_SCRIPT_NAME"]):【',dirname($_SERVER['ORIG_SCRIPT_NAME']),"】//如果PHP通过CGI来运行,这个变量的值就是/Php/Php.exe 如果Apache将PHP脚本作为模块来运行,该变量的值应该是/Phptest.php","<br/>";</span>
<span echo</span> "<br/>"<span ;

</span><span echo</span> "require_once "<span ;
</span><span require_once</span>("a/a.php");
Copy after login

/a/a.php

<?<span php
</span><span echo</span> "/a/a.php<hr/>"<span ;

</span><span echo</span> '$_SERVER["HTTP_HOST"]:【',<span $_SERVER</span>['HTTP_HOST'],"】//当前请求的 Host:即域名信信息","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["PHP_SELF"]:【<font color="#EE00EE">',<span $_SERVER</span>['PHP_SELF'],"</font>】//<font color='green'>请求执行文件的</font><font color='red'>相对</font><font color='blue'>地址</font>","<br/>"<span ;
</span><span echo</span> '$_SERVER["SCRIPT_NAME"]:【',<span $_SERVER</span>['SCRIPT_NAME'],"】//<font color='green'>实际执行文件</font><font color='red'>相对</font><font color='blue'>地址</font>","<br/>"<span ;
</span><span echo</span> '$_SERVER["SCRIPT_FILENAME"]:【',<span $_SERVER</span>['SCRIPT_FILENAME'],"】//<font color='green'>实际执行文件的</font><font color='red'>绝对</font><font color='blue'>路径</font>。","<br/>"<span ;
</span><span echo</span> '__FILE__ :【<font color="#EE00EE">',<span __FILE__</span> ,"</font>】//<font color='green'>实际执行代码的</font><font color='red'>绝对</font><font color='blue'>路径</font>。","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["REQUEST_URI"]:【',<span $_SERVER</span>['REQUEST_URI'],"】//url请求中包括/和之后的所有内容。","<br/>"<span ;
</span><span echo</span> '$_SERVER["QUERY_STRING"]:【',<span $_SERVER</span>['QUERY_STRING'],"】//url请求中?之后的内容。","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["DOCUMENT_ROOT"]:【',<span $_SERVER</span>['DOCUMENT_ROOT'],"】//文档根目录。在服务器配置文件中定义","<br/>"<span ;
</span><span echo</span> "<br/>"<span ;


</span><span echo</span> 'basename($_SERVER["PHP_SELF"]):【<font color="#EE00EE">',<span basename</span>(<span $_SERVER</span>['PHP_SELF']),"</font>】//<font color='green'>请求执行文件的</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename($_SERVER["SCRIPT_NAME"]):【',<span basename</span>(<span $_SERVER</span>['SCRIPT_NAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename($_SERVER["SCRIPT_FILENAME"]):【',<span basename</span>(<span $_SERVER</span>['SCRIPT_FILENAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename(__FILE__):【<font color="#EE00EE">',<span basename</span>(<span __FILE__</span>),"</font>】//<font color='green'>实际执行代码</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span //</span><span echo 'basename($_SERVER["ORIG_SCRIPT_NAME"]):【',basename($_SERVER['ORIG_SCRIPT_NAME']),"】//如果PHP通过CGI来运行,这个变量的值就是/Php/Php.exe 如果Apache将PHP脚本作为模块来运行,该变量的值应该是/Phptest.php","<br/>";</span>
<span echo</span> "<br/>"<span ;


</span><span echo</span> 'dirname($_SERVER["PHP_SELF"]):【<font color="#EE00EE">',<span dirname</span>(<span $_SERVER</span>['PHP_SELF']),"</font>】//<font color='green'>请求执行文件的</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname($_SERVER["SCRIPT_NAME"]):【',<span dirname</span>(<span $_SERVER</span>['SCRIPT_NAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname($_SERVER["SCRIPT_FILENAME"]):【',<span dirname</span>(<span $_SERVER</span>['SCRIPT_FILENAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname(__FILE__):【<font color="#EE00EE">',<span dirname</span>(<span __FILE__</span>),"</font>】//<font color='green'>实际执行代码</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span //</span><span echo 'dirname($_SERVER["ORIG_SCRIPT_NAME"]):【',dirname($_SERVER['ORIG_SCRIPT_NAME']),"】//如果PHP通过CGI来运行,这个变量的值就是/Php/Php.exe 如果Apache将PHP脚本作为模块来运行,该变量的值应该是/Phptest.php","<br/>";</span>
<span echo</span> "<br/>"<span ;

</span><span echo</span> "require_once "<span ;
</span><span require_once</span>("b/b.php");
Copy after login

/a/b/php

<?<span php
</span><span echo</span> "/a/b/b.php<hr/>"<span ;

</span><span echo</span> '$_SERVER["HTTP_HOST"]:【',<span $_SERVER</span>['HTTP_HOST'],"】//当前请求的 Host:即域名信信息","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["PHP_SELF"]:【<font color="#EE00EE">',<span $_SERVER</span>['PHP_SELF'],"</font>】//<font color='green'>请求执行文件的</font><font color='red'>相对</font><font color='blue'>地址</font>","<br/>"<span ;
</span><span echo</span> '$_SERVER["SCRIPT_NAME"]:【',<span $_SERVER</span>['SCRIPT_NAME'],"】//<font color='green'>实际执行文件</font><font color='red'>相对</font><font color='blue'>地址</font>","<br/>"<span ;
</span><span echo</span> '$_SERVER["SCRIPT_FILENAME"]:【',<span $_SERVER</span>['SCRIPT_FILENAME'],"】//<font color='green'>实际执行文件的</font><font color='red'>绝对</font><font color='blue'>路径</font>。","<br/>"<span ;
</span><span echo</span> '__FILE__ :【<font color="#EE00EE">',<span __FILE__</span> ,"</font>】//<font color='green'>实际执行代码的</font><font color='red'>绝对</font><font color='blue'>路径</font>。","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["REQUEST_URI"]:【',<span $_SERVER</span>['REQUEST_URI'],"】//url请求中包括/和之后的所有内容。","<br/>"<span ;
</span><span echo</span> '$_SERVER["QUERY_STRING"]:【',<span $_SERVER</span>['QUERY_STRING'],"】//url请求中?之后的内容。","<br/>"<span ;
</span><span echo</span> '<br/>'<span ;
</span><span echo</span> '$_SERVER["DOCUMENT_ROOT"]:【',<span $_SERVER</span>['DOCUMENT_ROOT'],"】//文档根目录。在服务器配置文件中定义","<br/>"<span ;
</span><span echo</span> "<br/>"<span ;


</span><span echo</span> 'basename($_SERVER["PHP_SELF"]):【<font color="#EE00EE">',<span basename</span>(<span $_SERVER</span>['PHP_SELF']),"</font>】//<font color='green'>请求执行文件的</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename($_SERVER["SCRIPT_NAME"]):【',<span basename</span>(<span $_SERVER</span>['SCRIPT_NAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename($_SERVER["SCRIPT_FILENAME"]):【',<span basename</span>(<span $_SERVER</span>['SCRIPT_FILENAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span echo</span> 'basename(__FILE__):【<font color="#EE00EE">',<span basename</span>(<span __FILE__</span>),"</font>】//<font color='green'>实际执行代码</font>的<font color='blue'>文件名</font>","<br/>"<span ;
</span><span //</span><span echo 'basename($_SERVER["ORIG_SCRIPT_NAME"]):【',basename($_SERVER['ORIG_SCRIPT_NAME']),"】//如果PHP通过CGI来运行,这个变量的值就是/Php/Php.exe 如果Apache将PHP脚本作为模块来运行,该变量的值应该是/Phptest.php","<br/>";</span>
<span echo</span> "<br/>"<span ;


</span><span echo</span> 'dirname($_SERVER["PHP_SELF"]):【<font color="#EE00EE">',<span dirname</span>(<span $_SERVER</span>['PHP_SELF']),"</font>】//<font color='green'>请求执行文件的</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname($_SERVER["SCRIPT_NAME"]):【',<span dirname</span>(<span $_SERVER</span>['SCRIPT_NAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname($_SERVER["SCRIPT_FILENAME"]):【',<span dirname</span>(<span $_SERVER</span>['SCRIPT_FILENAME']),"】//<font color='green'>实际执行文件</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span echo</span> 'dirname(__FILE__):【<font color="#EE00EE">',<span dirname</span>(<span __FILE__</span>),"</font>】//<font color='green'>实际执行代码</font>的<font color='blue'>所在目录</font>","<br/>"<span ;
</span><span //</span><span echo 'dirname($_SERVER["ORIG_SCRIPT_NAME"]):【',dirname($_SERVER['ORIG_SCRIPT_NAME']),"】//如果PHP通过CGI来运行,这个变量的值就是/Php/Php.exe 如果Apache将PHP脚本作为模块来运行,该变量的值应该是/Phptest.php","<br/>";</span>
<span echo</span> "<br/>";
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440233.htmlTechArticleLocal server, domain name http://d.com, root path D:phpnowvhostsd.com.yii, relative root The directory has the code requeir_once /a/a.php in the file /x.php, and /a/a.php requeir_once/a/b/b.php...
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