trigger_error

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 .

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.