关于PHP中变量未定义的提示

来源:互联网 发布:汉仪旗黑字体下载 mac 编辑:程序博客网 时间:2024/05/04 10:15

在家里电脑上自己做的项目,移到外网上时出现大量如下提示:

Notice: Use of undefined constant values -assumed 'values' in D:\wamp\www\yp\index.php on line19

Notice: Use of undefined constant values - assumed 'values'in D:\wamp\www\yp\index.php on line 19

Notice: Use of undefined constant values - assumed 'values'in D:\wamp\www\yp\index.php on line 19

Notice: Use of undefined constant values - assumed 'values'in D:\wamp\www\yp\index.php on line 19

Notice: Use of undefined constant values - assumed 'values'in D:\wamp\www\yp\index.php on line 19

Notice: Use of undefined constant values - assumed 'values'in D:\wamp\www\yp\index.php on line 19

Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.php on line 32

Notice: Use of undefined constant id - assumed 'id' inD:\wamp\www\yp\index.php on line 32

Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.php on line 32

Notice: Use of undefined constant id - assumed 'id' inD:\wamp\www\yp\index.php on line 32

Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.php on line 40

猛的一看,有点懵了,本来调试的好好的,怎么会突然出现错误?

翻译了下提示的意思,才明白原来PHP中允许中变量不经过声明而直接使用,但是如果设置了error_reporting后所有错误全显示的话,就会就出现提示,所以我们在写代码时最好养成习惯,变量使用前最好先声明

 

解决方案自然是设置下error_reporting打开php.ini将error_reporting = E_ALL 后面加上& ~E_NOTICE

或者在全局配置文件里写error_reporting(0)