Jun9 updates
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
defined('DEBUG') || define('DEBUG', $debug ?? $config['DEBUG'] ?? false);
|
||||
|
||||
if (ob_get_level() === 0) {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
function debug($msg) {
|
||||
error_log($msg);
|
||||
if (DEBUG > 1) print($msg . "\n");
|
||||
}
|
||||
register_shutdown_function(function () {
|
||||
$error = error_get_last();
|
||||
|
||||
if ($error !== null) {
|
||||
// Log fatal error details
|
||||
$type = $error['type'];
|
||||
$message = $error['message'];
|
||||
$file = $error['file'];
|
||||
$line = $error['line'];
|
||||
|
||||
echo "[SHUTDOWN] Fatal error: {$message} in {$file} on line {$line}\n";
|
||||
// Optional: log to file
|
||||
// file_put_contents('/path/to/shutdown.log', "[SHUTDOWN] ...\n", FILE_APPEND);
|
||||
} else {
|
||||
if (DEBUG > 1) {
|
||||
DEBUG && header('Content-Type: text/plain');
|
||||
# define('X','Well');
|
||||
DEBUG && print("Constants\n".print_r((get_defined_constants(true))['user']??'No Constants', true) . "\n");
|
||||
DEBUG && print("Functions\n".print_r((get_defined_functions(true))['user']??'No Functions', true) . "\n");
|
||||
DEBUG && print("Variables\n".print_r(array_diff_key(get_defined_vars(), array_flip(['_SERVER','_GET','_POST','_COOKIE', '_FILES'])), true) . "\n");
|
||||
DEBUG && print("Includes\n".print_r(get_included_files(), true) . "\n");
|
||||
}
|
||||
echo "[SHUTDOWN] Script completed normally.\n";
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user