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

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

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 values - assumed 'values' in D:\wamp\www\yp\index.php on line 19

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

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

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

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

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

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

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

 

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值