PHP have some predefine variable in which one of the most important type of variables are server variables. Basically Server variable which is define as $_SERVER is an array, which contain the information about headers, paths, browser information, the IP address, and which web page the visitor came from etc. The information in this array are created and store by the web server. This is also possible that some of the information will not provides by the server.
You can get all the information store in server variable array with the help of foreach loop.
$key_value) { print $key_name . " = " . $key_value . "
"; } ?>
Syntax :
$_SERVER['Server_Variable'];
For example :
$display = $_SERVER['PHP_SELF'];
Display the opened page name.
$display= $_SERVER['SERVER_NAME'];
Display the server name (website name) in our website it display the learninghints.com.
$display= $_SERVER['SERVER_SOFTWARE'];
Display the the software of webserver. in our case Apache
Variables in PHP
PHP Concatenation
Calculation in PHP
If Statements in PHP
if ... else Statements in PHP
Nested IF Structure in PHP
PHP Comparison Operators
Switch Statement in PHP
Logical Operators In PHP
PHP Booleans
FOR Loop in PHP
While Loop In PHP
foreach Loop In PHP
Break Statement
Array In PHP
Associative Array
The Count function
Changing Case Function
Trim Function In PHP
Str_shuffle( ) function
strpos function in PHP
Explode() Function in PHP
Function
Passing Function Arguments
Server Variables
Header Function
Include Function
The require Function