In runtime the log file contains the message I set to the argument of trigger_error
. The page is blank after that ! Is it possible to continue code execution after trigger_error
?
The trigger_error() function creates a user-level error message. The trigger_error() function can be used with the built-in error handler, or with a user-defined function set by the set_error_handler() function.
Definition and Usage The trigger_error() function creates a user-defined error message. The trigger_error() function is used to trigger an error message at a user-specified condition. It can be used with the built-in error handler, or with a user defined function set by the set_error_handler() function.
Used to trigger a user error condition, it can be used in conjunction with the built-in error handler, or with a user defined function that has been set as the new error handler (set_error_handler()). This function is useful when you need to generate a particular response to an exception at runtime.
No, trigger_error()
does not stop execution unless you pass the second argument as E_USER_ERROR
. By default it triggers a warning. You must have an error at some point after the call.
Trigger Warning:
trigger_error("CTest message"); // defaults to E_USER_NOTICE
Trigger Fatal Error:
trigger_error("Test message", E_USER_ERROR);
It depends on what the second parameter you pass to the trigger_error()
function, $error_type
, is. Some will display the error and stop execution, others will display an error and continue (note, the display is also based on your error_reporting
and display_errors
settings).
For instance, if you call:
trigger_error('This is an error', E_USER_ERROR);
Your script will stop execution.
However, if you call:
trigger_error('This is a warning', E_USER_WARNING);
Your script will not stop.
By default, trigger_error()
uses E_USER_NOTICE
which does not stop execution.
The full list of error types can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With