Home > Backend Development > PHP Tutorial > Remember how to handle PHP level errors. PHP concurrent processing. PHP queue processing for high concurrency. PHP processing json data.

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
1231 people have browsed it

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

<code>try{}catch(Exception $e){}
</code>
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:

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

Error reporting attempt:

<code>$a = 1/0;
</code>
Copy after login

Obtained results:

<code>int(2) string(16) "Division by zero"
</code>
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