What exactly is PATH_INFO in PHP?

江枫思渺然 提交于 2019-11-26 18:51:59
Andrew Moore

Actually, PATH_INFO is related to the Apache Web Server serving PHP pages and not PHP per se.

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.

The variable is accessible in PHP using $_SERVER['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.

Apache Core Documentation: AcceptPathInfo Directive

SimonSimCity

As the variable PATH_INFO is part of the definition for CGI you should also take a look in there ;)

https://tools.ietf.org/html/rfc3875#section-4.1.5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!