This is the code that works in the development environment:
PHP Code:
<?php
// Error handling
function errorHandler($num, $str, $file, $line) {
$text = "error {$num} in {$file}, line {$line}: {$str}\n";
$errorlog = "absolute path to my_log";
$new = file_exists($errorlog) ? false : true;
if($handle = fopen($errorlog, 'a')) { //append
fwrite($handle, $text);
fclose($handle);
if($new) { chmod($errorlog, 0755); }
} else {
//stuff noting that nothing was logged
}
}
function fatalHandler() {
$error = error_get_last();
if( $error !== NULL && $error['type'] == E_ERROR) {
errorHandler($error["type"], $error["message"], $error["file"], $error["line"]);
header('Location: [url]http://huluganfantasy.altervista.org/public/error.php');
header('Status: 500 Internal Server Error');
}
}
set_error_handler("errorHandler");
register_shutdown_function("fatalHandler");
?>
Karl, it would save everyone a lot of trouble, if Altervista provided us a direct option to create a log for recording, and to turn of display errors. Maybe you could allow limited use of the ini_set function for only that purpose, or some other alternative? That way even parse errors could be handled.