Remember how to handle PHP level errors. PHP concurrent processing. PHP queue processing for high concurrency. PHP processing json data.

WBOY
Release: 2016-07-29 08:50:50
Original
1080 people have browsed it

data-id="1190000005075466" data-license="nd">

try{}catch(Exception $e){}
Copy after login
in

php is not omnipotent, because it can only catch exceptions, but not PHP-level errors.

If you want to capture PHP-level errors and handle them like exceptions, the method is as follows:


set_error_handler(function($errno, $errmsg) {
    var_dump($errno, $errmsg);
    // Any other Do
});
Copy after login

Error reporting attempt:

$a = 1/0;
Copy after login

Obtained results:

int(2) string(16) "Division by zero"
Copy after login

Reference:

  1. A Q&A on this site

The above introduces how to handle a PHP level error, including the handling method and PHP content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!