Kamis, 04 Desember 2025

Most Common $_SERVER Variables

These following list are about most common PHP $_SERVER Variables:

Request Information:

  • $_SERVER['REQUEST_METHOD'] - switch the Request method to (e.g. GET, POST, PUT, DELETE, etc.)
  • $_SERVER['REQUEST_URI'] - The URI used to access the page
  • $_SERVER['QUERY_STRING'] - Query string if accessed via URL

Server Information:

  • $_SERVER['SERVER_NAME'] - Server hostname
  • $_SERVER['SERVER_ADDR'] - Server IP address
  • $_SERVER['SERVER_PORT'] - Port being used (usually 80 or 443)
  • $_SERVER['SERVER_SOFTWARE'] - Server identification string

Script Information:

  • $_SERVER['PHP_SELF'] - Filename of currently executing script
  • $_SERVER['SCRIPT_NAME'] - Path of current script
  • $_SERVER['SCRIPT_FILENAME'] - Absolute path of current script
  • $_SERVER['DOCUMENT_ROOT'] - Root directory of the server

Client Information:

  • $_SERVER['REMOTE_ADDR'] - IP address of the client
  • $_SERVER['REMOTE_PORT'] - Port being used by client
  • $_SERVER['HTTP_USER_AGENT'] - User agent string of the client
  • $_SERVER['HTTP_REFERER'] - Referring page URL (if available)

Protocol Information:

  • $_SERVER['HTTPS'] - Set to non-empty value if using HTTPS
  • $_SERVER['REQUEST_SCHEME'] - http or https

You can view all available server variables with print_r($_SERVER); or var_dump($_SERVER);

<< back to Study About PHP

Bibliography

  1. https://www.coursera.org/
  2. https://www.engadget.com/
  3. https://www.freecodecamp.org
  4. https://www.geeksforgeeks.org/
  5. https://www.php.net/ ( manual ebook )
  6. https://techcrunch.com/
  7. https://www.techradar.com/
  8. https://teamtreehouse.com/
  9. https://www.tutorialspoint.com/
  10. https://www.udemy.com/
  11. https://www.w3schools.com/
  12. Apache HTTP Server ebook;McGraw Hill
  13. Apache HTTP Server ebook;In Easy Steps
  14. Apache HTTP Server ebook;Packt
  15. PHP ebook;Apress
  16. PHP ebook;Sitepoint
  17. SQL ebook;O'Reilly
  18. SQL ebook;Manning
  19. SQL ebook;For Dummies