Last active
August 29, 2015 13:57
-
-
Save thewinterwind/9816795 to your computer and use it in GitHub Desktop.
View PHP server-related global variables from command line or browser
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
| <?php | |
| /** | |
| * Author: Anthony Vipond | |
| * Tested on: PHP 5.5 | |
| */ | |
| $global_indexes = ['SERVER', 'ENV', 'SESSION', 'REQUEST', 'COOKIE', 'GET', 'POST', 'FILES']; | |
| if (php_sapi_name() !== 'cli') { | |
| echo "<pre>"; | |
| } | |
| foreach ($global_indexes as $index) { | |
| if (isset($GLOBALS['_' . $index])) { | |
| $global = $GLOBALS['_' . $index]; | |
| } else { | |
| $global = '$GLOBAL["' . $index . '"] is not set'; | |
| } | |
| print '$_' . $index . ': ' . PHP_EOL; | |
| print_r($global); | |
| if (php_sapi_name() !== 'cli') { | |
| echo "<hr/>"; | |
| } else { | |
| print "---------\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment