$_SERVER Variable is an array containing information such as headers, paths, and script locations. That Information are created by the web server.
It is not sured that every website server will provide similar information.
If PHP is running as a command-line processor this variable contains the script name since ... Note: Your web server must be configured to create this variable.
Syntax=>$_SERVER['predefine_variable']
ex. echo $_SERVER['HTTP_HOST'];
Output-localhost/websitename
Following predefine server Variable using php
Ex. This example output of $_SERVER taken from localhost
<?php
echo $_SERVER['HTTP_HOST'];
echo "<pre>";
print_r($_SERVER);
echo "</pre>";
?>
It is not sured that every website server will provide similar information.
If PHP is running as a command-line processor this variable contains the script name since ... Note: Your web server must be configured to create this variable.
Syntax=>$_SERVER['predefine_variable']
ex. echo $_SERVER['HTTP_HOST'];
Output-localhost/websitename
Following predefine server Variable using php
Ex. This example output of $_SERVER taken from localhost
<?php
echo $_SERVER['HTTP_HOST'];
echo "<pre>";
print_r($_SERVER);
echo "</pre>";
?>
- [HTTP_HOST] => localhost/websitename
- [HTTP_CONNECTION] => keep-alive
- [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
- [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
- [HTTP_REFERER] => http://localhost/test/
- [HTTP_ACCEPT_ENCODING] => gzip,deflate,sdch
- [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.8
- [HTTP_COOKIE] => __atuvc=59%7C40%2C156%7C41%2C1%7C42
- [PATH] => C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
- [SystemRoot] => C:\Windows
- [COMSPEC] => C:\Windows\system32\cmd.exe
- [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
- [WINDIR] => C:\Windows
- [SERVER_SIGNATURE] =>
- [SERVER_SOFTWARE] => Apache/2.2.4 (Win32) PHP/5.2.1
- [SERVER_NAME] => localhost
- [SERVER_ADDR] => 127.0.0.1
- [SERVER_PORT] => 80
- [REMOTE_ADDR] => 127.0.0.1
- [DOCUMENT_ROOT] => C:/wamp/www
- [SERVER_ADMIN] => webmaster@localhost
- [SCRIPT_FILENAME] => C:/wamp/www/test/server.php
- [REMOTE_PORT] => 58329
- [GATEWAY_INTERFACE] => CGI/1.1
- [SERVER_PROTOCOL] => HTTP/1.1
- [REQUEST_METHOD] => GET
- [QUERY_STRING] =>
- [REQUEST_URI] => /test/server.php
- [SCRIPT_NAME] => /test/server.php
- [PHP_SELF] => /test/server.php
- [REQUEST_TIME] => 1382009753
- [argv] => Array ( )
- [argc] => 0
No comments:
Post a Comment