php Undefined index和Undefined variable的解决方法
参考资料:http://www.jb51.net/article/13974.htm
问题:
上传一个PHP网站到服务器,提示:
PHP Notice: Undefined index: user in C:\inetpub\wwwroot\xonixwatch.com\manager\index.php on line 7
PHP Notice: Undefined index: passwd in C:\inetpub\wwwroot\xonixwatch.com\manager\index.php on line 7
PHP Notice: Undefined variable: manager_dir in C:\inetpub\wwwroot\xonixwatch.com\manager\index.inc on line 29
PHP Notice: Undefined index: PATH_INFO in C:\inetpub\wwwroot\xonixwatch.com\manager\index.php on line 8
原因:
由于变量未定义引起的
解决方法:
本来php是不需要定义变量的,但是出现这种情况应该怎么办呢?
修改php.ini
将: error_reporting = E_ALL
修改为:error_reporting = E_ALL & ~E_NOTICE
如果什么错误都不想让显示,直接修改:
display_errors = Off
如果你没有php.ini的修改权限,可在php头部加入
ini_set("error_reporting","E_ALL & ~E_NOTICE");
即可