Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

pathinfo - What exactly is PATH_INFO in PHP?

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.

I've seen PATH_INFO several times, but still don't know what exactly it is. What does it do?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...