How to display all PHP server variables

Sometimes I get confused with what result a server variables would return.  For example between the $_SERVER[‘SCRIPTNAME’] and $_SERVER[‘SCRIPT_FILENAME’].

Use the following code to display all server variables. From there you can decide which server variable is suitable to use.

1
2
3
4
echo "<table>";
foreach($_SERVER as $key=>$value)
        echo "<tr><td>$key</td><td>$value</td></tr>";
echo "</table>";

Leave a Reply

Your email address will not be published. Required fields are marked *