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"; } });