Php parsing process

Source: Internet
Author: User
: This article mainly introduces the php parsing process. if you are interested in the PHP Tutorial, you can refer to it. We all know the execution process of PHP scripts. First, the Zend Engine compiles the PHP source code into an opcode sequence, and then the Zend VM will explain the execution. Generally, the process of compilation is to perform lexical analysis and syntax analysis first, and then compile. After syntax analysis, there is an abstract syntax Tree (AbstractSyntax Tree or AST), which is the output of syntax analysis, the subsequent compilation process is based on the AST by the compiler.

However, PHP is quite special. the Zend Engine directly produces opcode after syntax analysis and does not generate AST. The biggest advantage of doing so is to speed up the compilation process. The disadvantage is that it loses some freedom, is difficult to optimize, and leads to complicated compilation program logic. A wiki on the official PHP website discusses introducing AST during PHP compilation. of course, it is very difficult to implement it.

We generally do not have access to the PHP compilation process at ordinary times, but AST is a useful thing. many tools in our work usually contain AST, such as PHP_CodeSniffer, PHP_Depend, ZendStudio, and PDT, when you need to analyze the source code, you need AST to help you more or less.

Next, let's take a look at the PHP 7 and php5 compilation processes,


The above describes the php parsing process, including the content, and hope to help those who are interested in the PHP Tutorial.

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.