PHP code execution flow

 


    how about it? A little understanding of it. To be honest, just look at this, I am a bit ignorant, but, do not be afraid. Let's look slowly.

    First of all, find online information said that the order of execution of PHP code is this, the first step is lexical analysis, parsing the second step is the third step is converted to the opcode, which is the fourth part of the implementation of these opcode sequence.

    Smart as you see here, and then return to the top to look at this picture, certainly there will be a different feeling. Let's illustrate this sentence borrow steps: When a piece of code to get PHP, through lexical resolution, the syntax parsing phases, a source program is translated into instructions (with opcodes), and then sequentially executes the virtual machine ZEND instructions to complete the operation.

    As we all know, PHP itself is implemented in C, so C is a function of the final call, in fact, we can put PHP seen as a C software development. That being the case, then the core of PHP code execution is translated in a single instruction, here is the opcode.

    So, we can put the opcode seen as the basic unit of PHP code execution. So the essence of PHP code execution also can be understood as, our code will eventually be translated into a set of opcode handler, and then execute the order after bin.

    With these cognitive After, we will look at what this opcode ghost. Essentially a two opcode parameters (op1, op2), the function return value and the composition process. It's official explanation is that the PHP script compiler intermediate language, similar to the java bytecode or .net in the MSL.

    Its role is as follows:

    1, the principles of the middle of the process will produce a compiler intermediate code (language), the PHP (C language) from the intermediate Zend engine Opcode compiled code is then handed over to the processing engine Zend, as the C language compiler code is then compiled handed over to the compilation.

    2, resulting Opcode as an intermediate language, can help achieve not open source PHP source code, if you do not want others to know how your PHP code is written, you can use the APC interception directly generate Opcode cache file, then use own PHP extension for Opcode encryption program to encrypt and decrypt files, decrypt before the Zend engine for Opcode parse and execute again.


Original: https: //blog.csdn.net/luyaran/article/details/80776167

Guess you like

Origin www.cnblogs.com/yangjinqiang/p/10951606.html