Last active
July 8, 2022 02:09
-
-
Save tom--/5876699 to your computer and use it in GitHub Desktop.
Inspect your globals. Include this file to display any globals that might be defined. Maybe exit() afterwards.
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 | |
/** | |
* Inspect your globals. | |
* | |
* Include this file to display any globals that might be defined. Maybe exit() afterwards. | |
* | |
* @author Tom Worster <fsb@thefsb.org> | |
* @link https://gist.github.com/tom--/5876699 | |
* @copyright Copyright © 2013 Tom Worster | |
* @license BSD 2-clause http://opensource.org/licenses/BSD-2-Clause | |
*/ | |
call_user_func( | |
/** | |
* @param bool $html If true, generates an HTML document with <pre>formatted display of globals | |
*/ | |
function ($html = true) { | |
$globs = array(); | |
foreach ($GLOBALS as $k => $v) { | |
if (!preg_match('{^(?:GLOBALS|_SERVER|_GET|_POST|_FILES|_COOKIE|_SESSION|_REQUEST|_ENV)$}', $k)) { | |
$globs[$k] = $v; | |
} | |
} | |
$dump = var_export($globs, 1); | |
if ($html) { | |
$dump = | |
"<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=\"utf-8\"> | |
<title>Global variables</title> | |
</head> | |
<body> | |
<pre>$dump</pre> | |
</body> | |
</html>"; | |
} | |
echo $dump; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment