Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

How we use Custom errors and error triggers error handling method in PHP?
In Custom errors and error triggers,we handle errors by 
using self made functions.
1.Custom errors : By using this can handle the multiple 
errors that gives multiple message.
Syntax:
set_error_handler(\"Custom_Error\"); 
In this syntax if we want that our error handle, handle
only one error than we write only one argument otherwise
for handle multiple errors we can write multiple arguments.
Example:
<?php
//function made to handle errorfunction 
custom_Error($errorno, $errorstr)  
{   
   echo \"<b>Error:</b> [$errorno] $errorstr\";  }
//set error handler like that
set_error_handler(\"custom_Error\");
//trigger to that error
echo($verify);?>
2.error trigger : In PHP we use error trigger to handle
those kind of error when user enter some input data.If 
data has an error than handle by error trigger function.
Syntax:
<?php
$i=0;if ($i<=1)
{
trigger_error(\"I should be greater than 1 \");
}
?> 
In this trigger_error function generate error when i is
less than or greater than 1.