trigger_error
trigger_error
It generates a user-level error/warning/notice message.
Syntax:
void trigger_error ( string error_msg [, int error_type])
Description
The trigger_error() function takes two parameters: the string output message to be printed out as the error, and an optional second parameter of the type of error, want to issue. The first parameter can be whatever our wish, (eg: “Function called with wrong number of parameter”), - it is just a string that is sent directly to users
The second parameter, however, affects how the script should react to the error. If we do not provide the second parameter, the default is a user notice - a minor message that many people might not even see. However, we can select from any of the user error types as the second parameter, which can allow to halt execution of the script if our error is triggered.
Using trigger_error() is better than just printing an error message and exiting the script because trigger_error() takes the form of PHP’s default errors - it will automatically print out the filename and line number where the error occurred. Furthermore, it will uses PHP’s default settings, which allow to ignore certain classes of errors .
