0

let's say i have this code:

$a = 3 //forgot semicolon

is there a way to prevent the script from crashing, detect the error, call a custom function that will record the php error inside a custom error log file instead of the default php error log in php.ini, and also record this in the database.

I have tried the set_error_handler function, and try and catch but these are not suitable for this kind of scenario.

Noobit
  • 11
  • 2

1 Answers1

0

The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.

https://www.php.net/manual/en/function.set-error-handler.php

Alex Barker
  • 4,316
  • 4
  • 28
  • 47