Home  >  Article  >  Backend Development  >  apache Undefined index: PATH_INFO,该怎么解决

apache Undefined index: PATH_INFO,该怎么解决

WBOY
WBOYOriginal
2016-06-13 13:18:071940browse

apache Undefined index: PATH_INFO
Notice: Undefined index: PATH_INFO in 

这个是这么回事?网上搜了一把,没找到解决方法

页面里是这样的 $_SERVER['PATH_INFO']

如何让apache下的PHP支持$_SERVER['PATH_INFO']


需要改什么设置?

------解决方案--------------------
页头加上: error_reporting(E_ALL & ~E_NOTICE) ;

------解决方案--------------------
apache、iis都是默认支持的
不过你是要用了才会有的
比如
http://localhost/test.php/a/b/c

只要 test.php 存在,且不报错。则 test.php 中 $_SERVER['PATH_INFO'] 就有了
------解决方案--------------------
手册上说:
'PATH_INFO'
包含由客户端提供的、跟在真实脚本名称之后并且在查询语句(query string)之前的路径信息,如果存在的话。例如,如果当前脚本是通过 URL http://www.example.com/php/path_info.php/some/stuff?foo=bar 被访问,那么 $_SERVER['PATH_INFO'] 将包含 /some/stuff。 

你访问的url不对,因此不存在 path_info ,就出现了notice错误,不过你可以屏蔽它。

Statement:
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