Created
February 21, 2017 16:11
-
-
Save smartdeal/871c2228f8da35fb8b5e0471410643f6 to your computer and use it in GitHub Desktop.
PHP errors to file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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