Home > Article > Backend Development > PHP basics six error handling
The content of this article is about error handling of PHP Basics Six, which has a certain reference value. Now I share it with everyone. Friends in need can refer to it
<!-- 错误处理 --> <?php //php错误处理之禁止显示错误(display_errors) ini_set('display_error', 0); echo '服务器中display_errors的状态为'.ini_get('display_errors'); ?> <!-- php错误处理值错误报告级别 --> <?php // E_ERROR // E_WARNING // E_NOTICE // E_PARSE // E_ALL // E_STRICT // E_DEPRECATED error_reporting(); @$fp = fopen('adsaf.txt', 'r'); echo 1; ?> <!-- php错误处理之错误记录日志 --> <?php // php.ini中的配置 // log_errors // log_errors_max_len // error_log(重点) echo ini_get('log_errors'); error_log("无法连接到数据库服务器服务器"); error_log('可以用邮件报告错误,让运维人员半夜 起床干活',1,'pig@php.cn'); error_log("我是一个错误哟",3,"d:/test/my-errors.log"); ?> <!-- php错误处理之自定义错误处理函数 --> <?php function customError($errno, $errstr, $errfile,$errline){ echo "<b> Custom error:</b> [$errno] $errstr <br />"; echo "Error on line $errline in $errfile<br/>"; echo "Ending Script"; exit; } set_error_handler("customError"); $test=2; if ($test > 1) { trigger_error("A custom error has been triggered"); } ?>
Related recommendations:
php basic five image processing
The above is the detailed content of PHP basics six error handling. For more information, please follow other related articles on the PHP Chinese website!