Error handling in php Reviewed by Momizat on . Type of Errors 1: E_ERROR 2: E_WARNING 4: E_PARSE 8: E_NOTICE 16: E_CORE_ERROR 32: E_CORE_WARNING 64: E_COMPILE_ERROR 128: E_COMPILE_WARNING 256: E_USER_ERROR 5 Type of Errors 1: E_ERROR 2: E_WARNING 4: E_PARSE 8: E_NOTICE 16: E_CORE_ERROR 32: E_CORE_WARNING 64: E_COMPILE_ERROR 128: E_COMPILE_WARNING 256: E_USER_ERROR 5 Rating: 0

Error handling in php

Type of Errors

1: E_ERROR
2: E_WARNING
4: E_PARSE
8: E_NOTICE
16: E_CORE_ERROR
32: E_CORE_WARNING
64: E_COMPILE_ERROR
128: E_COMPILE_WARNING
256: E_USER_ERROR
512: E_USER_WARNING
1024: E_USER_NOTICE
2048: E_STRICT
4096: E_RECOVERABLE_ERROR
8192: E_DEPRECATED
16384: E_USER_DEPRECATED

Code for Custom Error

error_reporting( E_ERROR );
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <support@phpshortnotes.com>' . "\r\n";
//$headers .= 'Cc: myboss@example.com' . "\r\n";
function handleError($errno, $errstr,$error_file,$error_line)
{

//error_log("\nError With = PHP\nError Date = ".date("Y-m-d h a")."\nError Type = $errno \nError Found = $errstr \nError File = $error_file on line ($error_line) \n--------------------------------------------------------------------------------------------------", 3, "error_log.txt");
 $errormsg= "Error: [$errno] $errstr - $error_file:$error_line";
 mail("manish@phpshortnotes.com","Error:- ",$errormsg,$headers);
 die();

}
//set error handler
set_error_handler("handleError");

Leave a Comment

© 2014 Powered By