Explain the PHP request-response lifecycle from the moment a request hits the web server to the final HTML output.

Last updated 15 June 2026

  • The web server (Nginx or Apache) hands the request to PHP via PHP-FPM (FastCGI worker) or embedded mod_php.

  • PHP compiles the script to opcodes (cached by OPcache), populates superglobals like $_GET, and the Zend Engine runs it, often through a framework's router, controllers and views.

  • Output and headers return through the server as the HTTP response. Then PHP tears down all request state (shared-nothing), so each request starts fresh.

  • https://en.wikipedia.org/wiki/PHP
  • https://lemon.io/for-developers/php-developer-jobs/
  • https://lan-portal.uob.edu.ly/visit/BOOK/529X432U02/modern-php_new__features_and_good-practices.pdf
  • https://lan-portal.uob.edu.ly/upload/MD/D57953S372/modern-php__new_features_and__good__practices.pdf
  • https://news.ycombinator.com/item?id=30786927
  • https://kvnc-inc.medium.com/solid-principles-in-php-1c41069e9af6
  • https://www.shkodenko.com/
  • https://confoo.ca/en/2024/sessions
All PHP interview questions