Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php提示Notice: Undefined variable的解决办法

php提示Notice: Undefined variable的解决办法

发布时间:2015-01-29   编辑:www.jquerycn.cn
调试程序时出现 Undefined variable错误,一般情况下php是不需要定义变量的,但如果服务器什么都报错的,就会出现错误,所以服务器上都是应该屏蔽这种错误的。

调试程序时出现 Undefined variable错误,一般情况下php是不需要定义变量的,但如果服务器什么都报错的,就会出现错误,所以服务器上都是应该屏蔽这种错误的。
Notice: Undefined variable: email in D:\PHP5\ENOTE\ADDNOTE.PHP on line 9
Notice: Undefined variable: subject in D:\PHP5\ENOTE\ADDNOTE.PHP on line 9
Notice: Undefined variable: comment in D:\PHP5\ENOTE\ADDNOTE.PHP on line 9
........

其实以上就是未定义变量,就直接判断变量的代码导致。
本来php是不需要定义变量的,但是出现这种情况应该怎么办呢?
只要在C:\WINDOWS找出php.ini的
在php.ini中的302行 error_reporting = E_ALL
修改成
error_reporting = E_ALL & ~E_NOTICE
再重启apache2.2就行了

解决方法:修改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");
即可

您可能感兴趣的文章:
php错误Undefined variable: 如何解决
PHP运行出现Notice : Use of undefined constant 的解决方法
php提示Notice: Undefined variable的解决办法
php出现Notice : Use of undefined constant 的解决方法
php中出现Undefined index和Undefined variable的解决方法
php报错Notice: Undefined variable的解决办法
PHP Notice: undefined index原因与解决办法
解决PHP提示Notice: Undefined variable的办法
php提示Undefined variable: 引发的几个操作php-fpm等
php提示Notice: Undefined index 错误解决办法

关键词: php错误  Undefined variable   
[关闭]