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

來源:互聯網
上載者:User
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(); //恢複錯誤資訊指標

http://www.bkjia.com/PHPjc/632341.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632341.htmlTechArticlephp教程 錯誤報表開啟詳細實現 定義和用法 error_reporting() 設定 php 的報錯層級並返回當前層級。 文法 error_reporting(report_level)如果參數 level...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.