Last active
March 20, 2024 06:44
-
-
Save waimea-cpy/529a0af32b99c1e2cdd2d614051d0706 to your computer and use it in GitHub Desktop.
PHP Debug - PHP function to show debug global array debug info in small sidebar
This file contains 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
<?php | |
/*------------------------------------------------------------- | |
* Display debug info at bottom right of window (shows on hover) | |
* for the standard PHP arrays: GET / POST / FILE / SESSION, as | |
* well as the contents of a global $DEBUG variable which can | |
* be set to any value when debugging code. | |
*-------------------------------------------------------------*/ | |
function showDebugInfo() { | |
global $DEBUG; | |
$debugInfo = '<div style="background: rgba(0,0,0,0.8); color: #fff; font-size: 1rem; line-height: 1rem; position: fixed; right: 0; bottom: 1rem; padding: 0.5rem 1rem 0.5rem 0.25rem; width: 1rem; max-width: 95vw; max-height: 90vh; border-radius: 0.5rem 0 0 0.5rem; display: flex; gap: 1rem; overflow-x: hidden; overflow-y: auto; z-index: 999; cursor: pointer;" | |
onclick="this.style.width= this.style.width==\'auto\' ? \'1rem\' : \'auto\';">'; | |
$debugInfo .= '<div style="writing-mode: sideways-lr; text-align: center; color: #ff0;">DEBUG INFO</div>'; | |
$debugInfo .= '<pre style="margin: 0; font-size: 0.8rem; line-height: 0.8rem; text-align: left; ">'; | |
if( (isset( $DEBUG ) && sizeof( $DEBUG ) > 0) ) $debugInfo .= 'DEBUG '.print_r( $DEBUG, True ); | |
if( (isset( $_POST ) && sizeof( $_POST ) > 0) ) $debugInfo .= 'POST '.print_r( $_POST, True ); | |
if( (isset( $_GET ) && sizeof( $_GET ) > 0) ) $debugInfo .= 'GET '.print_r( $_GET, True ); | |
if( (isset( $_FILES ) && sizeof( $_FILES ) > 0) ) $debugInfo .= 'FILES '.print_r( $_FILES, True ); | |
if( (isset( $_SESSION ) && sizeof( $_SESSION ) > 0) ) $debugInfo .= 'SESSION '.print_r( $_SESSION, True ); | |
$debugInfo .= '</pre></div>'; | |
echo $debugInfo; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment