Using PHP to display all Server Variables


Simple PHP Script to dump all server variables

     This simple PHP script can be a huge help when trouble shooting server variable related issues, like when using load balancers and in this case IIS with ARR. The way I used this script was to check and see if the HTTP_X_FORWARDED_PROTO had been set by my ARR load balancers to prevent loops when offloading SSL. Using this script to test and see if URL Rewrite is setting the correct variable when you want it to can save you tons of time when creating rewrite rules!

Simply copy and paste the following PHP code into a test.php file and test from your server. Where the script needs to be run from depends on where your looking for the variable. In my case with ARR, the test.php is on the web server not the ARR controller but the site is loaded via the load balance address to verify that ARR/URL Rewrite is setting the correct variable. Note I would recommend removing it when your done as this shows a lot of valuable information about your server!


foreach($_SERVER as $key_name => $key_value) {

print $key_name . ” = ” . $key_value . “<br>”;



Comments are closed.