Home > Article > Backend Development > A brief introduction to the underlying design of PHP7 01-PHP7 language execution principle
PHP is an interpreted language. Unlike compiled languages, the compilation result is the instruction of the current CPU system. PHP source code can only be directly executed by the zend virtual machine when it is compiled into opcode.
The following is a brief description of the PHP7 language execution principle:
1. The source code first uses the lexical analyzer implemented by Re2c for lexical analysis, and cuts the source code into multiple String unit, the divided string is called Token;
2. The syntax analyzer implemented based on Bison generates an abstract syntax tree from Token and code that conforms to BNF grammar rules;
3. Abstract syntax tree (AST) is compiled to generate opcode; process.
Not only that, unlike Java and other languages that are resident in memory, the memory will be released immediately after the PHP code is executed, and basically all data will be destroyed at this time (only a very small amount of data will be cached).
Reference materials
1. Chen Lei, PHP7 underlying design and source code implementation
2. Lie Xusong, Chen Wen, PHP core technology and best practices
The above is the detailed content of A brief introduction to the underlying design of PHP7 01-PHP7 language execution principle. For more information, please follow other related articles on the PHP Chinese website!