Chapter 1: How PHP Executes—from Source Code to Render
by Thomas Punt
Peer reviewed by Younes Rafie.
Introduction
There's a lot going on under the hood when we execute a piece of PHP code. Broadly speaking, the PHP interpreter goes through four stages when executing code:
- Lexing
- Parsing
- Compilation
- Interpretation
This piece will skim through these stages and show how we can view the output from each stage to really see what is going on. Note that while some of the extensions used should already be a part of your PHP installation (such as tokenizer and OPcache), others will need to be manually installed and enabled (such as php-ast and VLD).
Stage 1 - Lexing
Lexing (or tokenizing) is the process of turning a string (PHP source code, in this ...
Get Better PHP Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.