Last active
December 29, 2015 10:39
-
-
Save zgardner/7658233 to your computer and use it in GitHub Desktop.
Debugging PHP scripts that don't finish
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
<? | |
global $LOG_FILE_NAME; | |
$LOG_FILE_NAME = session_save_path() . '/' . uniqid('log_file_') . microtime(true); | |
file_put_contents($LOG_FILE_NAME . '.START', print_r($_REQUEST, true) . print_r($_SERVER, true) . print_r($_SESSION, true)); | |
function log_file_shutdown_function () { | |
global $LOG_FILE_NAME; | |
file_put_contents($LOG_FILE_NAME . '.END', microtime(true)); | |
} | |
register_shutdown_function('log_file_shutdown_function'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script can be used as an auto_prepend_file for PHP scripts that don't correctly terminate. If you look for a START file without an END, you can see what request caused it. From this blog: http://keyholesoftware.com/2013/11/18/intro-to-scaling-php-part1