PHP E_USER_ERROR
The E_USER_ERROR is a custom error that can be triggered by developers when coding.
By. Jacob
Edited: 2020-02-25 15:33
E_USER_ERROR is a user-defined error type in PHP that can be triggered by developers from within their scripts. To trigger a user-error, we may use the trigger_error function in a script.
We may only trigger the E_USER_* error types with trigger_error. When an error is triggered, it will function similarly to PHP's build-in errors, and if logging is enabled it will also get written to the server log.
The E_USER_ERROR is intended for non-recoverable errors, similar to E_ERROR errors thrown by PHP.
E_USER_ERROR will also be handled by a custom error handler if defined.
Note. It is probably better to throw an exception rather than relying too much on triggering errors. The trigger_error(); function may still have uses, such as informing of deprecated features by triggering E_USER_DEPRECATED.
To trigger a E_USER_ERROR, we can do like shown below:
trigger_error("A required file did not exist!", E_USER_ERROR);
Tell us what you think: