Skip to content

Instantly share code, notes, and snippets.

@thewinterwind
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save thewinterwind/9816795 to your computer and use it in GitHub Desktop.

Select an option

Save thewinterwind/9816795 to your computer and use it in GitHub Desktop.
View PHP server-related global variables from command line or browser
<?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