PHP中的PATH_INFO到底是什么? [英] What exactly is PATH_INFO in PHP?
问题描述
所有外部URL看起来都像'module/action?key1 = param1'.无法进行自定义-但速度很快. 区别在于,第一个使用PHP的GET,第二个使用PATH_INFO.
all external URLs look like 'module/action?key1=param1'. No customization possible--but it's fast. The difference is that the first uses PHP's GET, and the second uses PATH_INFO.
我已经看过几次PATH_INFO
,但是仍然不知道它到底是什么.它是做什么的?
I've seen PATH_INFO
several times, but still don't know what exactly it is. What does it do?
推荐答案
实际上,PATH_INFO
与服务PHP页面的Apache Web服务器有关,而与PHP本身无关.
Actually, PATH_INFO
is related to the Apache Web Server serving PHP pages and not PHP per se.
PATH_INFO
是Apache在
PATH_INFO
is an environment variable set by Apache when the AcceptPathInfo
directive is turned on. It will contain trailing pathname information that follows an actual filename or non-existent file in an existing directory, whether the request is accepted or rejected. Environment variables are then passed on to the Apache/CGI module in charge of rendering the page.
可以使用$_SERVER['PATH_INFO']
在PHP中访问该变量.
The variable is accessible in PHP using $_SERVER['PATH_INFO']
.
例如,假设位置/test/
指向仅包含单个文件here.html
的目录.然后,对/test/here.html/more
和/test/nothere.html/more
的请求都将/more
收集为PATH_INFO
.
For example, assume the location /test/
points to a directory that contains only the single file here.html
. Then requests for /test/here.html/more
and /test/nothere.html/more
both collect /more
as PATH_INFO
.
这篇关于PHP中的PATH_INFO到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!