关于PHP.INI中的错误ERROR报告级别设置
最近在写php的过程中发现php提示php notice:………………的字样,虽然这个只是php的提示内容,并没有什么大的影响,但是出于安全性和美观方面的考虑,小弟还是想把这个东西去掉。
那么,怎么办呢?
抬出baidu,直接复制、粘贴php notice:,这样搜索的结果,一般有两种情况:
一、直接来一句:error_reporting=E_ALL&~E_NOTICE,搞得你不知道什么意思?!
二、
1.在php.ini文件中改动error_reporting 改为:
error_reporting=E_ALL&~E_NOTICE
如果你不能操作php.ini文件,你可以用下面的方法来实现
2.在你想禁止notice错误提示的页面中加入下面的代码
/* Report all errors except E_NOTICE */
error_reporting(E_ALL ^ E_NOTICE);
希望上面的代码能解决你的问题。 这个还好一些,让你知道怎么搞!打开php.ini,ctrl+f找到error_reporting,把上面的ctrl+v过来,浏览自己的网页,诶,真的不显示php notice了,这时真是对这位大哥感激的不行啊,终于帮我们这些菜鸟们解决问题了。 但是,不要急着关闭php.ini,让我们好好看看我们的php.ini:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; error_reporting is a bit-field. Or each number up to get desired error
; reporting level
; E_ALL - All errors and warnings (doesn't include E_STRICT)
; E_ERROR - fatal run-time errors
; E_RECOVERABLE_ERROR - almost fatal run-time errors
; E_WARNING - run-time warnings (non-fatal errors)
; E_PARSE - compile-time parse errors
; E_NOTICE - run-time notices (these are warnings which often result
; from a bug in your code, but it's possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it's automatically initialized to an
; empty string)
; E_STRICT - run-time notices, enable to have PHP suggest changes
; to your code which will ensure the best interoperability
; and forward compatibility of your code
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
; initial startup
; E_COMPILE_ERROR - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR - user-generated error message
; E_USER_WARNING - user-generated warning message
; E_USER_NOTICE - user-generated notice message
;
; Examples:
;
; - Show all errors, except for notices and coding standards warnings
;
;error_reporting = E_ALL & ~E_NOTICE
;
; - Show all errors, except for notices
;
;error_reporting = E_ALL & ~E_NOTICE | E_STRICT
;
; - Show only errors
;
;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
;
; - Show all errors, except coding standards warnings
;
error_reporting = E_ALL 虽然是英文的,但是就这么几个英文单词,应该难不倒我们吧!
看完,你会发觉,搜索出来的解决办法似乎不大好,而应该这样:
去掉;error_reporting = E_ALL & ~E_NOTICE这一句全面的;就可以了。
这样做比搜索出来的解决办法简单,而且这样做还保证了php.ini的完整性。 现在,再来看看在网页中对错误报告级别的控制吧!
拿出你的php手册,索引->error_reporting,看到了吧! The error_reporting() function sets the error_reporting directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script.
参数
level
The new error_reporting level. It takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for future versions. As error levels are added, the range of integers increases, so older integer-based error levels will not always behave as expected.
The available error level constants are listed below. The actual meanings of these error levels are described in the predefined constants.
表82.error_reporting() level constants and bit values
value constant
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
64 E_COMPILE_ERROR
128 E_COMPILE_WARNING
256 E_USER_ERROR
512 E_USER_WARNING
1024 E_USER_NOTICE
2047 E_ALL
2048 E_STRICT
4096 E_RECOVERABLE_ERROR
返回值
Returns the old error_reporting level.
范例
例543.error_reporting() examples
copy to clipboard
<?php
// Turn off all error reporting
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting(E_ALL);
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>
关于PHP.INI中的错误ERROR报告级别设置的更多相关文章
- mysql安装过程中出现错误ERROR 1820 (HY000): You must SET PASSWORD before executing this statement解决
mysql安装过程中出现错误ERROR 1820 (HY000): You must SET PASSWORD before executing this statement解决 最近新装好的my ...
- PHP的错误报错级别设置原理简析
原理简析 摘录php.ini文件的默认配置(php5.4): ; Common Values: ; E_ALL (Show all errors, warnings and notices inclu ...
- VC++中出现错误“ error c2065 'printf' undeclared identifier”的处理方法
原文:http://blog.csdn.net/panpan639944806/article/details/20135311 有两种可能: 1.未加头文件 #include <stdio.h ...
- PHP 错误与异常 笔记与总结(3)PHP 配置文件(php.ini)中与错误相关的选项 与 设置错误级别
[PHP 配置文件中与错误相关的选项 ] 选项 描述 error_reporting 设置错误报告的级别 display_errors 是否显示错误 log_errors 设置是否将错误信息记录到日志 ...
- PHP中的错误处理机制
常见的三种错误: 1.Notice :通知性错误,最小的错误,当发生通知性错误时,会弹出一个提示信息.不会中断代码的执行. 错误代码: #例如Notice: 2.Warning:警告性错误,当发生警告 ...
- PHP中的错误信息
PHP中的错误信息 php.ini中配置错误消息 在PHP4中,没有异常 Exception这个概念,只有 错误Error.我们可以通过修改php.ini 文件来配置用户端输出的错误信息. 在ph ...
- PHP中如何设置error_reporting错误报告级别
错误报告级别:指定了在什么情况下,脚本代码中的错误(这里的错误是广义的错误,包括E_NOTICE注意.E_WARNING警告.E_ERROR致命错误等)会以错误报告的形式输出. 设置错误报告级别的 ...
- Sql server2012连接Sql server 2008时出现的问题:已成功与服务器建立连接,但在登陆过程中发生错误。(provider:SSL Provider,error:0-接收到的消息异常,或格式不正确。)
以前连接是正常的,就这两天连不上了.(没有耐心的直接看末尾解决办法) 错误消息如下: 1.尝试读取或写入受保护的内存.这通常指示其他内存已损坏.(System.Data) 2.已成功与服务器建立连接, ...
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!&&在eclipse.ini中为eclipse指定jdk启动
参考:http://blog.csdn.net/zyz511919766/article/details/7442633 http://blog.sina.com.cn/s/blog_028f0c1c ...
随机推荐
- Nginx流量带宽请求状态统计(ngx_req_status)
介绍 ngx_req_status 用来展示 nginx 请求状态信息,类似于 apache 的 status, nginx 自带的模块只能显示连接数等等 信息,我们并不能知道到底 ...
- html语义化小记录
1.头部标签 <header></header> 2.大块集合 <article></article> 3.主要集和 <main></ ...
- 用Storyboard构建标签栏多页面应用程序UI
注: 貌似CSDN的显示效果不佳,假设有须要的话我能够上传pdf格式的: 另外假设文章中有错误还请给位多多提意见,谢谢. pdf格式文档:http://download.csdn.net/detail ...
- Lucene的学习及使用实验
实验一下Lucene是怎么使用的. 参考:http://www.importnew.com/12715.html (例子比较简单) http://www.yiibai.com/lucene/lucen ...
- VR虚拟现实的工作原理,你知道多少?【转】
VR虚拟现实经过几年的预热,已经开始呈现爆发式增长,要了解VR虚拟现实,就需要了解其工作原理,了解工作原理之前,我们就需要弄清楚眼睛是如何看清事物的. 眼睛瞳孔后有晶状体,也就是眼珠子.眼睛的背面有感 ...
- npm模块安装机制
npm 是 Node 的模块管理器,功能极其强大.它是 Node 获得成功的重要原因之一.正因为有了npm,我们只要一行命令:npm install,就能安装别人写好的模块 . 一.从 npm ins ...
- EL表达式介绍(1)
1. 产生背景: 在MVC体系结构中,JSP页面只是用来显示数据,但JSP脚本中的表达式功能不够强大,它不能直接对隐式对象中某对象的属性进行显示,需要配合 scriptlet才能显示数据,很是麻烦,如 ...
- 最小生成树之Prim(普里姆)算法
关于什么是Prim(普里姆算法)? 在实际生活中,我们常常碰到类似这种一类问题:如果要在n个城市之间建立通信联络网, 则连通n个城市仅仅须要n-1条线路.这时.我们须要考虑这样一个问题.怎样在最节省经 ...
- unity3D克隆50个游戏对象并输出Json格式的文本
http://wenku.baidu.com/link?url=tl8q_aj1n-U267XkKtSZISaw6jKJ1woh4CJkDUr1AwEzllSAv7P0r7cawXXSyDVXNf6m ...
- oracle新建一个表空间和用户来測试
首先对表空间作例如以下说明 暂时表空间:是在做大数据量排序时.分组操作时用的.正常这些都是在内存中完毕的.但在大数据量排序处理时.内存不够用的情况下就会用到暂时表空间,这里是不存放表的,有点类似于操作 ...