This might be handy if you don't want your clients to see the errors, and you do want to be one step ahead of them.
It emails you the errors even if it's a parse error.
set_error_handler() doesn't work for what I wanted.
<?php
ini_set('log_errors',TRUE);
ini_set('error_log','tiny_uploads/errors.txt');
if($_SERVER['REMOTE_ADDR'] != "YOUR IP ADDRESS"){
ini_set('display_errors',false);
}
function byebye(){
$dir = dirname(__FILE__);
if(file_exists($dir."/tiny_uploads/errors.txt")){
$errors = file_get_contents($dir."/tiny_uploads/errors.txt");
if(trim($errors)){
$head = "From: php_errors@".str_replace('www.','',$_SERVER['HTTP_HOST'])."\r\n";
$errors .= "---------------------------------------------\n\n";
$errors .= "\n\nServer Info:\n\n".print_r($_SERVER, 1)."\n\n";
$errors .= "---------------------------------------------\n\n";
$errors .= "\n\nCOOKIE:\n\n".print_r($_COOKIE, 1)."\n\n";
$errors .= "---------------------------------------------\n\n";
$errors .= "\n\nPOST:\n\n".print_r($_POST, 1)."\n\n";
$errors .= "---------------------------------------------\n\n";
$errors .= "\n\nGET:\n\n".print_r($_GET, 1)."\n\n";
mail("[email protected]","PHP Error ".$_SERVER['HTTP_HOST']."", $errors , $head);
$fp = fopen($dir."/tiny_uploads/errors.txt","w+");
fputs($fp, "");
fclose($fp);
}
}
}
register_shutdown_function("byebye");
?>