How to catch PHP fatal errors (`E_ERROR`)?
P粉978551081
2023-08-27 14:42:20
<p>I can use <code>set_error_handler()</code> to catch most PHP errors, but it does not work for fatal (<code>E_ERROR</code>) errors, such as calling a non-existent function. Is there any other way to catch these errors? </p>
<p>I'm trying to resolve all errors by calling <code>mail()</code> and am running PHP 5.2.3. </p>
Use
register_shutdown_function
to log fatal errors, this requires PHP 5.2:You must define the
error_mail
andformat_error
functions. For example:Use Swift Mailer to write the
error_mail
function.See also: