You will encounter many error handling methods in PHP learning. This article explains the related handling methods.
<?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"); } ?>
This article introduces the error handling mechanism. For more related content, please pay attention to the PHP Chinese website.
Related recommendations:
Comparative introduction to SESSION and COOKIE under PHP
Understand the method of obtaining the client IP in PHP
Detailed explanation on the use of Session in php
The above is the detailed content of PHP basic learning: error handling. For more information, please follow other related articles on the PHP Chinese website!