$_SERVER variable

$_SERVER is a predefined variables in php. This name is superglobals variable. which variable keep the server path ,file location and headers.

Syntax:

$_SERVER["server_variable"]

Example Code

$_SERVER['SERVER_NAME'];
$_SERVER['PHP_SELF'];
$_SERVER['HTTP_HOST'];
$_SERVER['HTTP_HOST'];
$_SERVER['HTTP_USER_AGENT'];
$_SERVER['HTTP_REFERER'];
$_SERVER['SCRIPT_NAME'];

Out Put:

$_SERVER['SERVER_NAME'] : www.tutorialsscripts.com
$_SERVER['PHP_SELF'] : /php-tutorials/php-server-variable.php
$_SERVER['HTTP_HOST'] : www.tutorialsscripts.com
$_SERVER['HTTP_HOST'] : www.tutorialsscripts.com
$_SERVER['HTTP_USER_AGENT'] : CCBot/2.0 (https://commoncrawl.org/faq/)
$_SERVER['HTTP_REFERER'] :
$_SERVER['SCRIPT_NAME'] : /php-tutorials/php-server-variable.php




Content