美文网首页
关于PHP中变量未定义的提示

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

作者: 卡卡西哥哥 | 来源:发表于2016-01-06 11:13 被阅读773次

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

    Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

    Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

    Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

    Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

    Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

    Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

    Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.phpon line32

    Notice: Use of undefined constant id - assumed 'id' inD:\wamp\www\yp\index.phpon line32

    Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.phpon line32

    Notice: Use of undefined constant id - assumed 'id' inD:\wamp\www\yp\index.phpon line32

    Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.phpon line40

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

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

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

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

    相关文章

      网友评论

          本文标题:关于PHP中变量未定义的提示

          本文链接:https://www.haomeiwen.com/subject/djpxkttx.html