php will call the compilation function zend_compile_file() to compile. The specific implementation of this function actually includes two main processes: lexical analysis (Lex implementation) and syntax analysis (Yacc implementation). After executing this function: the compilation of the php script is complete. The input of this function is: php script file, and the output is op_array. To put it simply: the compilation process is to parse the script into instructions that the php virtual machine can process, and op_array is these instructions It's just an array made (this is very similar to the assembly code generated by some
compiled languages, and it is also a series of commands).
The PHP virtual machine will then call the zend_execute() function to execute. The input of this function is the op_array generated in the compilation stage above, where it will parse each command and process it
. Since there are about 150 op commands in total, it needs to process these 150 commands. A very interesting question arises here: How does it handle these 150 commands
? First of all, each command has a corresponding processor for processing. Therefore: the virtual machine will be distributed to the corresponding processor for processing based on the type of each command in op_array.
The above is the detailed content of How php explains. For more information, please follow other related articles on the PHP Chinese website!