最近在写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);
?>

  

最新文章

  1. lvs/dr配置
  2. javascript类型系统——Number数字类型
  3. 高级c++头文件bits/stdc++.h
  4. 微软ASP.NET MVC 学习地址
  5. rfid门禁系统笔记
  6. Overview &amp; Change Log
  7. [Javascript] An Introduction to JSPM (JavaScript Package Manager)
  8. du和df不一致的解决方法
  9. string和double之间的相互转换(C++)
  10. django+Python数据库利用Echarts实现网页动态数据显示
  11. VC++ 6.0 中使用 MSComm.ocx
  12. 利用GUID唯一标识符并设置它的过期时间
  13. Java、Apache Tomcat下载与安装及环境变量配置
  14. ShowHand
  15. 用Kotlin破解Android版微信小游戏-跳一跳
  16. MySQL四种事务隔离级别详解
  17. linux系统nginx的https的跳转
  18. asp.net防SQL/JS注入攻击:过滤标记
  19. 第一篇:Hadoop简介
  20. MyEclips 2017/2018 (mac 版)安装与破解

热门文章

  1. JS面向对象之闭包
  2. java_hibernate
  3. UVA-10603-Fill(BFS+优先队列)
  4. http://blog.csdn.net/hahalzb/article/details/5889545
  5. Python使用matplotlib绘制三维曲线
  6. 转:ios的crash框架方法论
  7. 微信小程序 - 回到自己位置(map)
  8. Unity AssetBundle 踩坑记录
  9. 网页视频播放方案chimee 组件使用
  10. 使用jconsole监控tomcat(推荐配置)