Articles index » phpBB 3.0 » Trigger Error

Trigger Error

A simple overview of the trigger_error() function.

Submitted by harmlessgoat22 on 16 Apr 2008, 22:42

Trigger_error() is a function that can be used to stop everything in a php page or script and display a message. The "Information" message shown after adding a forum in the ACP is an example of trigger_error()

The general syntax for trigger_error() is the following.
Code: Select all
trigger_error($message[, error_type])    


$message is the error message you would like to be displayed. As phpBB 3.0 is multilingual it is possible to just specify the language key for $user->lang. If you need to connect messages though, you need to supply the full $user->lang variable (with key). For example:
Code: Select all
trigger_error('NO_MESSAGE');
trigger_error($user->lang['NO_MESSAGE'] . adm_back_link($this->u_action));   


There are three error types that can be used: E_USER_NOTICE, E_USER_WARNING, and E_USER_ERROR. If none is specified, E_USER_NOTICE is used. They are used for differen't things. E_USER_NOTICE is a "information" page. It's used for things like the message you get after creating a post or logging in. E_USER_WARNING is for errors. On normal pages it doesn't really make a difference, but in the ACP it creates a pink message box instead of a green one. The third is E_USER_ERROR, this should only be used for very bad errors, for example if sessions are unavaillable. It is used for things like SQL errors, most MODs will not need it.
 

Changelog:

by eviL<3 on 18 Apr 2008, 14:33: Expanded a little
by eviL<3 on 23 Apr 2008, 16:17: Fixed mistake reported by Rotsblok

License:

All articles in the knowledge base are licensed under the phpbbmodders beerware-nc license.

Back to category


Articles index » phpBB 3.0 » Trigger Error