How to turn errors into exceptions in PHP?
How to turn errors into exceptions in PHP?
Here's how you can turn errors into exceptions in PHP:
function errorHandler($errno, $errstr, $errfile, $errline) {
throw new Exception("Error: $errstr in $errfile on line $errline", $errno);
}
set_error_handler():set_error_handler('errorHandler');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ErrorException class to throw exceptions for specific error levels:Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.