6.PHP Kernel Explorer: Zend Engine

Source: Internet
Author: User
Tags php language

Believe that many people have heard of Zend engine this noun, there are many people know that Zend engine is the core of PHP language, but to ask: Zend engine in the end where it exists? Or, at what point does the Zend Engine play a role in letting PHP source output what we want?

The Zend engine is the core of the PHP implementation and provides the infrastructure for language implementations. For example: PHP syntax implementation, script compiler run environment, extension mechanism and memory management, of course, here PHP refers to the official PHP implementation (in addition to the official implementation, is now more well-known Facebook hiphop implementation, but so far, PHP does not yet have a standard language specification, while PHP provides the interface for request processing and other Web servers (SAPI).

To understand the role of Zend engine, you can not understand why it appears, why PHP needs Zend engine, Zend engine appears for PHP to solve the problem. PHP is now popular when it comes to version 3.0. "At the peak of PHP3, it was installed on 10% of Web servers on the Internet," says PHP Manual. A wide range of applications inevitably leads to higher requirements. But at this time the PHP3 is somewhat inadequate, this is mainly because the PHP3 uses the side to explain the operation of the side execution, the efficiency is very affected by it. Secondly, the overall coupling of the code is relatively high, the scalability is not good enough to cope with a variety of needs. As a result, Zeev Suraski and Andi Gutmans, who have a bit of a backbone in the PHP community, have decided to rewrite the code to address both issues. In the end they both named the core engine of the technology Zend engine,zend meaning Zeev + Andi.

The main feature of Zend Engine is to change the operation of the side interpretation side of PHP to pre-compile (Compile) before executing (execute). The separation of the two brings a revolutionary change to PHP: the efficiency of execution is greatly improved, and due to the separation of functions, the degree of coupling between modules is reduced and the scalability is greatly enhanced. At this point PHP can be very convenient to cope with a variety of BT requirements, and with PHP 4.4.x― may be the last branch of the PHP4 series-the release of PHP, most developers have focused on the PHP5 or PHP6, the release is basically some Bug Fix Release. It can be said that the first generation of the Zend Engine is already in the station the last shift.

In July 2004, PHP 5 was released and the Zend Engine 2.0 version was supported for PHP5. This version is mainly to improve the OO functionality of PHP (I did not mention the integration of SQLite, PDO and other features because we are talking about Zend Engine rather than PHP). The core execution mode (non-OO part) is less than the PHP4 version 1.0, so PHP5 's pure execution speed does not increase much compared to PHP4. PHP 5.1, which is expected to be released in the middle of this month, will carry the Zend Engine 2.1 version, which will provide a new way to execute, at least much faster than the PHP5.0 compared to php4.x, so PHP 5.1 will be a very The desired version.

But not the PHP5 series of Zend Engine 2 is perfect. As mentioned earlier, Zend Engine divides the code into two parts: compilation and execution. In general, our code is seldom changed after it is finished. But PHP has to have to repeat the compilation again and again at the time of execution, which is absolutely unnecessary. And typically, the time it takes to compile is no less than execution, which is 55 is not too much, so it's a huge waste of the machine's CPU. The PHP6 based on Zend Engine 3.0 will try to solve this problem. In addition, the current PHP for multibyte character processing is also a big fatal flaw in PHP. This is almost intolerable today as people connect increasingly to the international. It is always inevitable to mention this when countless people are attacking PHP or comparing similar languages such as ASP. At the same time, under pressure from IBM, PHP6 will also refer to the processing of multibyte characters as the primary agenda. This has been demonstrated in the Dev version of PHP6.

The current PHP implementation and Zend engine is very close, even some too close, for example, many PHP extensions are used by the Zend API, and Zend is the implementation of the PHP language itself, PHP just use Zend This kernel to build the PHP language, The PHP extension mostly uses the Zend API, which leads to a lot of PHP extensions and Zend engines that are coupled, and then the PHP core developers proposed to untie this coupling.

There is no doubt about the popularity of PHP at the moment, and any popular language will often appear in other implementations of the language, which is evident in the Java community, where there are already a lot of JVM-based languages, such as IBM's Project Zero, which implements a JVM-based PHP implementation , . NET also have similar implementations, usually they do this because they like the language, but do not want to abandon the original platform, or the existing language implementation is not satisfied with the performance or language characteristics (hiphop is born).

Many scripting languages have a language extension mechanism, the PHP extension is usually through the pear library or native extension, in Ruby, the boundary is not very obvious, they will even provide two sets of implementations, one is mainly used in the environment can not be compiled, and in the appropriate environment using the C implementation of the native extension, This can be guaranteed in both efficiency and portability. These extensions that are currently written for PHP are often not reusable in other PHP implementations, and the hiphop approach is to rewrite the most popular extensions. If the PHP extension can be decoupled from ZENDAPI, it will be easier to reuse these extensions in other languages.

6.PHP Kernel Explorer: Zend Engine

Related Article

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.