Forum

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

Reply

How we use Error logging error handling method in PHP?
In PHP,by default an error log send to the error log system.By using error logging we can send and error log to the specific file.
 We checked this by using an example.In this we send a mail to our self with error message.And the scripts does not work when error comes.
Example:
<?php
//error handler function
function customError($errorno, $errorstr)
 { 
    echo "<b>Error:</b> [$errno] $errorstr<br />";
    echo "program has been notified";
    error_log("Error: [$errorno] $errorstr",1,
           "abc@xyz.com","From: program@xyz.com");
 }
//set error handler
set_error_handler("customError",E_USER_WARNING);
//trigger error
$i=0;
if ($i<=1)
 {
    trigger_error("I should be greater than 1", E_USER_WARNING);
 }
?>
o/p:
[512] I should be greater than 1
program has been notified
Our mail have reply message like that,
Error: [512] I should be greater than 1