Posted By

chrisaiv on 11/23/09


Tagged

php server


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

adrianparr
lifewishes
tof


PHP: List of Server Variables


 / Published in: PHP
 

URL: http://php.net/manual/en/reserved.variables.server.php

Here's a pretty comprehensive list of Server variables I use.

  1. //Information about the Server we're on
  2. echo "SERVER_NAME: " . $_SERVER['SERVER_NAME'] . "<br />";
  3. echo "SERVER_ADDR: " . $_SERVER['SERVER_ADDR'] . "<br />";
  4. echo "SERVER_PORT: " . $_SERVER['SERVER_PORT'] . "<br />";
  5.  
  6. echo "<br /><br />";
  7.  
  8. //Where are all the files located
  9. echo "DOCUMENT_ROOT: " . $_SERVER['DOCUMENT_ROOT'] . "<br />";
  10. //Path on the URL Address bar
  11. echo "PHP_SELF: " . $_SERVER['PHP_SELF'] . "<br />";
  12. //Path on the filesystem
  13. echo "SCRIPT_FILENAME: " . $_SERVER['SCRIPT_FILENAME'] . "<br />";
  14.  
  15. //Request details
  16. echo "REMOTE_ADDR: " . $_SERVER['REMOTE_ADDR'] . "<br />";
  17. echo "REMOTE_Port: " . $_SERVER['REMOTE_PORT'] . "<br />";
  18. echo "REQUEST_URI: " . $_SERVER['REQUEST_URI'] . "<br />";
  19. echo "QUERY_STRING: " . $_SERVER['QUERY_STRING'] . "<br />";
  20. echo "REMOTE_METHOD: " . $_SERVER['REQUEST_METHOD'] . "<br />";
  21. echo "REMOTE_TIME: " . $_SERVER['REQUEST_TIME'] . "<br />";
  22. //Who referred them to our website (YAHOO? GOOGLE?)
  23. echo "HTTP_REFERER: " . $_SERVER['HTTP_REFERER'] . "<br />";
  24. //Statistics
  25. echo "HTTP_USER_AGENT: " . $_SERVER['HTTP_USER_AGENT'] . "<br />";

Report this snippet  

You need to login to post a comment.