PHP Syntax Variables Scope Superglobal $_SERVER

 

- Info:

- $_SERVER is superglobal associative array containing information created by the Web server.

 

- Example:

- Create PHP Console Application Test.php.

 

Test.php

<?php

//SOME VARIABLES FROM $_SERVER.

echo($_SERVER['REMOTE_ADDR' ]); //192.0.34.166.

echo($_SERVER['HTTP_USER_AGENT']); //Mozilla/5.0 (Windows; U; en-US; rv:1.8.0.10)Gecko/20070216

echo($_SERVER['REQUEST_URI' ]); //192.0.34.166.

echo($_SERVER['HTTP_REFERER' ]); //192.0.34.166.

echo($_SERVER['REMOTE_ADDR' ]); //192.0.34.166.

//LIST ALL VARIABLES FROM SUPERGLOBAL ARRAY $_SERVER.

foreach ($_SERVER as $var => $value) {

echo "$var => $value \n";

}

?>