程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php 錯誤報告開啟詳細實現

php 錯誤報告開啟詳細實現

編輯:關於PHP編程

php教程 錯誤報告開啟詳細實現

定義和用法
error_reporting() 設置 php 的報錯級別並返回當前級別。

語法
error_reporting(report_level)如果參數 level 未指定,當前報錯級別將被返回。下面幾項是 level 可能的值

*/
//關閉所有的錯誤報告
error_reporting(0);
//只報告運行錯誤
error_reporting(e_error|e_warning|e_parse);
//報告e_notice
error_reporting(e_error|e_warning|e_parse|e_notice);
//報告所有的運行錯誤,除了e_notice
//這是php.ini的默認值
error_reporting(e_all ^ e_notice);
//報告所有的php錯誤
error_reporting(e_all);
//和error_reporting(e_all)有一樣的功效,該設置也會報告所有php錯誤
ini_set('error_reporting', e_all);

/*

值 常量 描述
1 e_error fatal run-time errors. errors that can not be recovered from. execution of the script is halted
2 e_warning non-fatal run-time errors. execution of the script is not halted
4 e_parse compile-time parse errors. parse errors should only be generated by the parser
8 e_notice run-time notices. the script found something that might be an error, but could also happen when running a script normally
16 e_core_error fatal errors at php startup. this is like an e_error in the php core
32 e_core_warning non-fatal errors at php startup. this is like an e_warning in the php core
64 e_compile_error fatal compile-time errors. this is like an e_error generated by the zend scripting engine
128 e_compile_warning non-fatal compile-time errors. this is like an e_warning generated by the zend scripting engine
256 e_user_error fatal user-generated error. this is like an e_error set by the programmer using the php function trigger_error()
512 e_user_warning non-fatal user-generated warning. this is like an e_warning set by the programmer using the php function trigger_error()
1024 e_user_notice user-generated notice. this is like an e_notice set by the programmer using the php function trigger_error()
2048 e_strict run-time notices. php suggest changes to your code to help interoperability and compatibility of the code
4096 e_recoverable_error catchable fatal error. this is like an e_error but can be caught by a user defined handle (see also set_error_handler())
8191 e_all all errors and warnings, except level e_strict (e_strict will be part of e_all as of php 6.0)

*/

function unserialize_handler($errno,$errstr)     //自定義函數
{
  echo "invalid serialized value.n";       //輸出指定內容
}
$serialized='foo';          //定義字符串
set_error_handler('unserialize_handler');      //設置用戶自定義錯誤信息函數
$original=unserialize($serialized);       //從已存儲的表示中創建php的值
restore_error_handler();         //恢復錯誤信息指針

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved