Skip to content

Instantly share code, notes, and snippets.

@smartdeal
Last active May 8, 2018 15:00
Show Gist options
  • Save smartdeal/1c8afb32b196e160de52cdae0cdca9f5 to your computer and use it in GitHub Desktop.
Save smartdeal/1c8afb32b196e160de52cdae0cdca9f5 to your computer and use it in GitHub Desktop.
[PHP errors to file] #PHP-hack
<?php
set_error_handler('err_handler');
function err_handler($errno, $errmsg, $filename, $linenum) {
$date = date('Y-m-d H:i:s (T)');
$f = fopen('errors.log', 'a');
if (!empty($f)) {
$filename =str_replace($_SERVER['DOCUMENT_ROOT'],'',$filename);
$err = "$errmsg = $filename = $linenum\r\n";
fwrite($f, $err);
fclose($f);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment