Share on Google+Share on Google+

PHP Trigger Error

Advertisement
In the current tutorial we will study about trigger error method, This method is used to trigger an user level error message, it can be displayed along with the built-in-error handler, or with a user defined function. Along with it we will study what is the functionality of it, how it should be implemented etc.

PHP Trigger Error

PHP trigger_error generates an error, warning, notice message. Basic format of the trigger_error is as follows:

boolean trigger_error ( string $error_message <, int $error_type = E_USER_NOTICE >)

The return data type of this method is Boolean, first argument is necessary to mention and the next one is optional (that's why it is enclosed within angular bracket )

This method is used to trigger an user level error message, it can be displayed along with the built-in-error handler, or with a user defined function.

Example of PHP Trigger Error Handling:

<?php

$div=0;

if($div==0){

trigger_error("Cannot divide by zero");

}

?>

Output:

Notice: Cannot divide by zero in ../trigger_error.php on line 4

 

Advertisements

Advertisement

Posted on: March 5, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.