Thursday, October 17, 2013

Php Server Variable

$_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>";
?>

  1.  [HTTP_HOST] => localhost/websitename
  2. [HTTP_CONNECTION] => keep-alive
  3. [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  4. [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
  5. [HTTP_REFERER] => http://localhost/test/
  6. [HTTP_ACCEPT_ENCODING] => gzip,deflate,sdch
  7. [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.8
  8. [HTTP_COOKIE] => __atuvc=59%7C40%2C156%7C41%2C1%7C42
  9. [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;
  10. [SystemRoot] => C:\Windows
  11. [COMSPEC] => C:\Windows\system32\cmd.exe
  12. [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
  13. [WINDIR] => C:\Windows
  14. [SERVER_SIGNATURE] =>
  15. [SERVER_SOFTWARE] => Apache/2.2.4 (Win32) PHP/5.2.1
  16. [SERVER_NAME] => localhost
  17. [SERVER_ADDR] => 127.0.0.1
  18. [SERVER_PORT] => 80
  19. [REMOTE_ADDR] => 127.0.0.1
  20. [DOCUMENT_ROOT] => C:/wamp/www
  21. [SERVER_ADMIN] => webmaster@localhost
  22. [SCRIPT_FILENAME] => C:/wamp/www/test/server.php
  23. [REMOTE_PORT] => 58329
  24. [GATEWAY_INTERFACE] => CGI/1.1
  25. [SERVER_PROTOCOL] => HTTP/1.1
  26. [REQUEST_METHOD] => GET
  27. [QUERY_STRING] =>
  28. [REQUEST_URI] => /test/server.php
  29. [SCRIPT_NAME] => /test/server.php
  30. [PHP_SELF] => /test/server.php
  31. [REQUEST_TIME] => 1382009753
  32. [argv] => Array ( )
  33. [argc] => 0

No comments:

Post a Comment