PHP中的PATH_INFO到底是什么? [英] What exactly is PATH_INFO in PHP?

查看:114
本文介绍了PHP中的PATH_INFO到底是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有外部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在 指令已打开.无论请求是被接受还是被拒绝,它将包含尾随路径名信息,该路径名信息在现有目录中的实际文件名或不存在的文件之后.然后将环境变量传递给负责呈现页面的Apache/CGI模块.

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.

Apache核心文档:AcceptPathInfo指令

这篇关于PHP中的PATH_INFO到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆