Back in 1993, #RasmusLerdorf wrote a few CGI scripts in C just to maintain his personal homepage. He extended them to handle HTML forms and databases, calling it "Personal Home Page/Forms Interpreter" (PHP/FI). That humble side project eventually became the language powering ~80% of the web today. The name later evolved into the recursive acronym we know: Hypertext Preprocessor (PHP).
π Now here's what actually happens under the hood every time PHP runs:
β‘ SAPI Layer
Nginx/Apache receives your request and hands it off to PHP via FastCGI. Headers parsed, access checked β the boring stuff that matters.
π§ OPcache Check
PHP asks: "Have I seen this before?"
YES β Load compiled OpCodes from memory. Done. Fast.
NO β Time to compile...
π§ Compilation Pipeline
Lexer breaks your code into tokens
Parser builds an Abstract Syntax Tree (AST)
Compiler converts AST β OpCodes
βοΈ Zend Engine Execution
The heart of PHP. Executes OpCodes, runs your logic, queries your DB, builds the response.
π€ Output & Cleanup
Response gets Gzip compressed β sent to browser β PHP cleans up memory. Ready for the next request.
π‘PHP 8+ Bonus:
JIT compilation converts hot OpCodes directly into machine code. Even faster.
Top comments (0)