Important SERVER Variables in PHP - By PHP Expert


Consider your file is at location: http://www.example.com/index.php
static location for file is: /home/a/b/exampl/htdocs/
The following will be the values for the server variables

[HTTP_HOST] => www.example.com
//Indicates the domain name of your site

[HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
// Indicates from which browser you are accessing the site

[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
//what kind of content is requested by your file

[HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
//header from the current request, if there is one. Example 'en'

[HTTP_ACCEPT_ENCODING] => gzip,deflate
//header from the current request, if there is one. Example: 'gzip'

[HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
//header from the current request, if there is one. Example: 'iso-8859-1,*,utf-8'

[HTTP_KEEP_ALIVE] => 300
//header from the current request, if there is one to keep connection alive for given time.

[HTTP_CONNECTION] => keep-alive
//header from the current request, indicating whether to keep connection alive or not.

[HTTP_COOKIE] => __utma=123129419.826544571.1217935577.1219399309.1219416030.12; __utmz=123129419.1217935577.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); style=alt1

//shows the list of cookies currently set.

[HTTP_CACHE_CONTROL] => max-age=0
//amount for which we browser must control cache, its 0 means for unlimited period.

[PATH] => /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin

[SERVER_SIGNATURE] => Apache/2.0.52 (CentOS) Server at 192.168.1.101 Port 80
// Information about the webserver

[SERVER_SOFTWARE] => Apache/2.0.52 (CentOS)
//Information about the server software

[SERVER_NAME] => www.example.com
//The name of the server host under which the current script is executing.

[SERVER_ADDR] => 192.168.1.101
//The IP address of the server under which the current script is executing.

[SERVER_PORT] => 80 //The port on the server machine being used by the web server for communication.

[REMOTE_ADDR] => 192.168.1.178
//The Host name from which the user is viewing the current page.

[DOCUMENT_ROOT] => /home/a/b/exampl/htdocs/
//The document root directory under which the current script is executing, as defined in the server's configuration file.

[SERVER_ADMIN] => root@localhost
//The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.

[SCRIPT_FILENAME] => /home/a/b/exampl/htdocs/index.php
//The absolute pathname of the currently executing script.

[REMOTE_PORT] => 3924
//The port being used on the user's machine to communicate with the web server.

[GATEWAY_INTERFACE] => CGI/1.1
//What revision of the CGI specification the server is using; i.e. 'CGI/1.1'.

[SERVER_PROTOCOL] => HTTP/1.1
//Name and revision of the information protocol via which the page was requested; i.e. 'HTTP/1.0';

[REQUEST_METHOD] => GET
// Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'.

[QUERY_STRING] =>
//The query string, if any, via which the page was accessed.

[REQUEST_URI] => /
//The URI which was given in order to access this page; for instance, '/index.php'.

[SCRIPT_NAME] => /index.php
//Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

[PHP_SELF] => /index.php
//The filename of the currently executing script, relative to the document root.

[REQUEST_TIME] => 1219654851
//The timestamp of the start of the request. Available since PHP 5.1.0.

kevin@sdi.la
2008-09-05 06:52:41
Hi Nilesh, Just testing.
lavina@sdi.la
2008-09-02 02:57:45
test

Enter your email address:

Delivered by FeedBurner

OR

 Subscribe in a reader

 
 
 
Tips for optimizing php code by PHP Expert Important SERVER Variables in PHP - By PHP Expert Improved Error Messages in PHP 5 - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert Object Overloading in PHP 5 Persistable Classes - By PHP Expert Dynamic Getter/Setter Methods - By PHP Expert New Functions in PHP 5 New Directives - By PHP Expert Exception Handling - By PHP Expert Password Encryption in PHP - By PHP Expert Output Buffering in PHP - By PHP Expert Page Excerpts Using CURL - By PHP Expert Quick and Easy Google Site Search - By PHP Expert Always Be Notified When Google Crawls Your Site - By PHP Expert How to POST Form Data using CURL - By PHP Expert Cryptography for web developers - By PHP Expert Dynamically Loading JavaScript Files - by PHP Expert What is Web 2.0 - By PHP Expert