Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP's error levels

Tags:

php

The only error level in PHP that will halt the script but can be caught and dealt with have to be triggered with the trigger_error() function correct? I'm referring to the "E_USER_ERROR" error level. The "E_ERROR" error will simply halt the script and I can't do anything about it as the developer.

like image 702
lanmind Avatar asked Sep 25 '09 23:09

lanmind


Video Answer


1 Answers

E_ERROR will simply stop the script. It's meant to be used for:

Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.

Ref

You cannot handle the following other error types for similar reasons:

  • E_PARSE
  • E_CORE_ERROR
  • E_CORE_WARNING
  • E_COMPILE_ERROR
  • E_COMPILE_WARNING

set_error_handler() however can handle the follow errors:

  • E_WARNING
  • E_NOTICE
  • E_USER_ERROR (using trigger_error)
  • E_USER_WARNING (using trigger_error)
  • E_USER_NOTICE (using trigger_error)
  • E_STRICT
  • E_RECOVERABLE_ERROR
like image 81
Matthew Avatar answered Sep 19 '22 23:09

Matthew