自己在做php时突然出现php Notice : Use of undefined constant这种错误,一个就是变量未定义出问题,下面我们来看看解决办法吧。
错误提示
php Notice : Use of undefined constant
分析
这些是 PHP 的提示而非报错,PHP 本身不需要事先声明变量即可直接使用,但是对未声明变量会有提示。一般作为正式的网站会把提示关掉的,甚至连错误信息也被关掉
解决办法
立即学习“PHP免费学习笔记(深入)”;
关闭 PHP 提示的方法
搜索php.ini:
| 代码如下 | 复制代码 |
|
error_reporting = E_ALL 改为: error_reporting = E_ALL & ~E_NOTICE |
|
还有个不是办法的办法就是
在每个文件头上加
| 代码如下 | 复制代码 |
| error_reporting(0); 虽然不好弄但是可以解决问题 | |
外国参考文章
Hello,
You need to change your php.ini file
find the word "error_reporting" in your php.ini file and make the
change like below..
| 代码如下 | 复制代码 |
|
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT |
|
regards
R.Sureshkannan
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号