Hello everyone, today we are going to learn PHP $_SEVER variable. Which is a super global variable and contains header information, path information, script locations. They are available in all scopes throughout a script. Entries to this global variable is done by web server.

Below table describes $_SERVER variables and its use.

$_SERVER[‘PHP_SELF’] Return filename of currently executing file
$_SERVER[‘GATEWAY_INTERFACE’] Return the CGI of server (CGI – Common Gateway Interface.)
$_SERVER[‘SERVER_ADDR’] Return server IP address
$_SERVER[‘SERVER_NAME’] Return the name of server
$_SERVER[‘SERVER_SOFTWARE’] Returns server identification string
$_SERVER[‘SERVER_PROTOCOL’] Returns name and revision of information protocol.
$_SERVER[‘REQUEST_METHOD’] Returns request method (Eg: GET/POST)
$_SERVER[‘REQUEST_TIME’] Returns timestamp of the request
$_SERVER[‘QUERY_STRING’] Returns the query string, which the page accessed
$_SERVER[‘HTTP_ACCEPT’] Returns accepted contents (eg:ext/html,application/xhtml+xml etc)
$_SERVER[‘HTTP_ACCEPT_CHARSET’] Accept_charset from current request header
$_SERVER[‘HTTP_HOST’] Returns host name of the request
$_SERVER[‘HTTP_REFERER’] Complete path of the file where it is located
$_SERVER[‘REMOTE_ADDR’] IP address from where the user is viewing the current file.
$_SERVER[‘REMOTE_HOST’] Host name from where the user is viewing the current file
$_SERVER[‘REMOTE_PORT’] Returns port number where the clients machine is communicating with web server
$_SERVER[‘SCRIPT_FILENAME’] Absolute pathname of the file where it is located.
$_SERVER[‘SERVER_ADMIN’] The value given to the server admin directive in the web server configuration file
$_SERVER[‘SERVER_PORT’] Return the port used for web server communication
$_SERVER[‘SERVER_SIGNATURE’] Server version and virtual host name.
$_SERVER[‘PATH_TRANSLATED’] Returns file system
$_SERVER[‘SCRIPT_NAME’] path of current script
$_SERVER[‘SCRIPT_URI’] URI of current page

Leave a Reply

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