PHP Trigger Error


 

PHP Trigger Error

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.

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

 

Ads