PHP运行出现Notice : Use of undefined constant 的完美解决方案分享

2015-01-24信息快讯网

今天修改公司的网站,提示Notice : Use of undefined constant ,通过下面的方法解决了,最好是error_reporting(0);不需要更改配置

Notice: Use of undefined constant ALL_PS - assumed 'ALL_PS' in E:\Server\vhosts\www.lvtao.net\global.php on line 50

Notice: Undefined index: EaseTemplateVer in E:\Server\vhosts\www.lvtao.net\libs\template.core.php on line 51

Notice: Use of undefined constant uid - assumed 'uid' in E:\Server\vhosts\www.lvtao.net\global.php on line 54

Notice: Undefined index: uid in E:\Server\vhosts\www.lvtao.net\global.php on line 54

Notice: Use of undefined constant cuid - assumed 'cuid' in E:\Server\vhosts\www.lvtao.net\global.php on line 55

Notice: Undefined index: cuid in E:\Server\vhosts\www.lvtao.net\global.php on line 55

Notice: Use of undefined constant shell - assumed 'shell' in E:\Server\vhosts\www.lvtao.net\global.php on line 56

Notice: Undefined index: shell in E:\Server\vhosts\www.lvtao.net\global.php on line 56

Notice: Use of undefined constant cshell - assumed 'cshell' in E:\Server\vhosts\www.lvtao.net\global.php on line 57

Notice: Undefined index: cshell in E:\Server\vhosts\www.lvtao.net\global.php on line 57

Notice: Use of undefined constant username - assumed 'username' in E:\Server\vhosts\www.lvtao.net\global.php on line 58

Notice: Undefined index: username in E:\Server\vhosts\www.lvtao.net\global.php on line 58

Notice: Use of undefined constant cusername - assumed 'cusername' in E:\Server\vhosts\www.lvtao.net\global.php on line 59

Notice: Undefined index: cusername in E:\Server\vhosts\www.lvtao.net\global.php on line 59

Notice: Use of undefined constant id - assumed 'id' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 10

Notice: Use of undefined constant id - assumed 'id' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 14

Notice: Use of undefined constant content - assumed 'content' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 16

Notice: Use of undefined constant content - assumed 'content' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 16

Notice: Use of undefined constant description - assumed 'description' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 17

Notice: Use of undefined constant description - assumed 'description' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 17

Notice: Use of undefined constant provinceid - assumed 'provinceid' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 18

Notice: Use of undefined constant cityid - assumed 'cityid' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 19

Notice: Use of undefined constant hy - assumed 'hy' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 20

Notice: Undefined variable: content in E:\Server\vhosts\www.lvtao.net\libs\template.core.php on line 557

进入网站会出现大量类似下面的提示,但是可以正常显示和运行

Notice: Use of undefined constant ctbTitle - assumed 'ctbTitle' in d:\ctb1.5\ctb\include\config.php on line 23...

b答案:这些是 PHP 的提示而非报错,PHP 本身不需要事先声明变量即可直接使用,但是对未声明变量会有提示。一般作为正式的网站会把提示关掉的,甚至连错误信息也被关掉

关闭 PHP 提示的方法

搜索php.ini:

error_reporting = E_ALL

改为:

error_reporting = E_ALL & ~E_NOTICE

还有个不是办法的办法就是

在每个文件头上加

error_reporting(0); 虽然不好弄但是可以解决问题!!!!!!这个比较好用
深入Memcache的Session数据的多服务器共享详解
基于PHP输出缓存(output_buffering)的深入理解
php缓冲 output_buffering的使用详解
Window下PHP三种运行方式图文详解
win7+apache+php+mysql环境配置操作详解
探讨php define()函数及defined()函数使用详解
基于php iconv函数的使用详解
PHP在不同页面间传递Json数据示例代码
使用session判断用户登录用户权限(超简单)
探讨如何把session存入数据库
深入php define()函数以及defined()函数的用法详解
解析php中mysql_connect与mysql_pconncet的区别详解
phpmyadmin显示utf8_general_ci中文乱码的问题终级篇
PHP和.net中des加解密的实现方法
Fine Uploader文件上传组件应用介绍
PHP提示Notice: Undefined variable的解决办法
php提示undefined index的几种解决方法
PHP中文件读、写、删的操作(PHP中对文件和目录操作)
php在服务器执行exec命令失败的解决方法
JS中encodeURIComponent函数用php解码的代码
mysql总结之explain
MySQL时间字段究竟使用INT还是DateTime的说明
一些需要禁用的PHP危险函数(disable_functions)
php中echo()和print()、require()和include()等易混淆函数的区别
ThinkPHP写第一个模块应用
PHP持久连接mysql_pconnect()函数使用介绍
PHP中register_globals参数为OFF和ON的区别(register_globals 使用详解)
PHP的博客ping服务代码
PHP中创建空文件的代码[file_put_contents vs touch]
Trying to clone an uncloneable object of class Imagic的解决方法
openPNE常用方法分享
PHP及Zend Engine的线程安全模型分析
php数组函数序列之array_combine() - 数组合并函数使用说明
PHP Undefined index报错的修复方法
提高define性能的php扩展hidef的安装和使用
Notice: Undefined index: page in E:\PHP\test.php on line 14
©2014-2024 dbsqp.com