PHP parsing process

Source: Internet
Author: User
Tags php source code php website
We all know the PHP script execution process, first by the Zend engine to compile the PHP source code into a opcode sequence, and then by the Zend VM to explain the execution. The general compilation process is the first lexical analysis, syntax analysis, and then the compilation. After parsing, there is the concept of an abstract syntax tree (abstractsyntax tree or abbreviated AST), which is the output of the parsing, and then the compiler is based on the AST.

But PHP is special, the Zend engine produces opcode directly after parsing, without generating an AST. The greatest benefit of this is to speed up the compilation process, and the downside is the loss of some freedom, the difficulty of optimization, and the complexity of compiling the program logic. There is a wiki on the specific PHP website that explores the introduction of AST in the process of compiling PHP, which is certainly quite difficult to achieve.

We usually do not have access to the PHP compilation process, but AST is a useful thing, we usually work in a lot of tools have AST, such as Php_codesniffer, Php_depend, Zendstudio, PDT, need to analyze the source of the occasion , more or less need AST's help.

Let's look at the PHP7 and PHP5 compilation process,


The above describes the PHP parsing process, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.