easiest way to print all php $_SERVER variables

http://php.net/manual/en/reserved.variables.server.php:

foreach (filter_input_array(INPUT_SERVER) as $key => $value) {
    echo '$_SERVER["'.$key.'"] = '.$value."<br />";
}

update:

for some unknown reason, that code only prints $_SERVER[“PHP_SELF”] variable on my siteground server…

better (and even easier) using phpinfo(), that also prints $_SERVER variables.

update2:

this is the reason for filter_input_array not working on siteground shared hosting:
https://bugs.php.net/bug.php?id=49184&thanks=6
http://php.net/manual/en/function.filter-input.php#77307

i found i nice debug utility (http://phpdebugbar.com/) that also displays $_SERVER superglobal variables.

Advertisements

One thought on “easiest way to print all php $_SERVER variables

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s