Does trigger_error interrupt script interruption?

At run time, the log file contains the message that I set for the trigger_error argument. After that, the page is empty! Is it possible to continue code execution after trigger_error ?

+8
php
source share
2 answers

No, trigger_error() does not stop execution unless you pass the second argument as E_USER_ERROR . By default, it triggers a warning. You should have an error at some point after the call.

Trigger Warning:

 trigger_error("CTest message"); // defaults to E_USER_NOTICE 

Trigger start error:

 trigger_error("Test message", E_USER_ERROR); 
+11
source share

It depends on which second parameter you pass trigger_error() , $error_type , is. Some will display an error and stop execution, others will display an error and continue (note that the screen is also based on the error_reporting and display_errors settings).

For example, 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.

A complete list of error types can be found here .

+1
source share

All Articles