Development History of Zend Engine (1) _ PHP Tutorial

Source: Internet
Author: User
Development History of Zend Engine (1 ). Zeev discusses the object model brought about by the Zend Engine. it is particularly mentioned that it is different from the model in the previous versions of PHP. when we developed PHP3 in the summer of 1997, we did not plan to make PHP have Zeev and discussed the object model brought about by the Zend Engine, it is particularly mentioned that it is different from the models in the previous versions of PHP. when PHP 3 was developed in the summer of 1997, we did not plan to make PHP object-oriented. at that time, there was no idea about classes and objects. PHP3 is a purely process-oriented language. however, the class support is added to the PHP3 alpha version on the evening of 1997.8.27. A new feature was added to PHP, which was rarely discussed at the time, because there were too few people exploring PHP. since August 1997, PHP has taken the first step towards object-oriented programming language.

Indeed, this is only the first step. there are only a few related ideas in this design, and the support for objects is not strong enough. in this version, using objects is only a cool way to access arrays. instead of using $ foo ["bar"], you can use $ foo-> bar that looks more beautiful. the main advantage of object-oriented methods is to store functions through member functions or methods. the example shows a typical code block. however, it is not very different from the practice in the example.

Object-oriented programming in PHP 3 object-oriented programming PHP3

<?php    class Example    {        var $value = "some value";        function PrintValue()        {            print $this->value;        }    }    $obj = new Example();    $obj->PrintValue(); ?>

Structured programming in PHP 3 structural programming PHP3 PHP3

<?php    function PrintValue($arr)    {        print $arr["value"];    }    function CreateExample()    {        $arr["value"] = "some value";        $arr["PrintValue"] = "PrintValue";        return $arr;    }    $arr = CreateExample();    //Use PHP's indirect reference    $arr["PrintValue"]($arr); ?>

The above two lines of code are written in the class, or an array is passed to the function explicitly. however, considering that the two options in PHP3 are not different, we can still use the object model as a "syntactic whitewashing" to access the array.

People who want to use PHP for object-oriented development, especially those who want to use design patterns, will soon find them hitting the wall. fortunately, not many people in the PHP3 era wanted to use PHP for object-oriented development.

PHP4 has changed this situation. the new version introduces the reference concept, which allows different PHP identifiers to point to the same address in the memory. this means that you can use two or more names to name the same variable, as in the example.

Reference in PHP 4 references PHP4

<? Php $ a = 5; // $ B points to the same place in memory as $ a $ B and $ a point to the same address in the memory $ B = & $; // we're changing $ B, since $ a is pointing to Change $ B, address changed/the same place-it changes too $ a address also changed $ B = 7; // prints 7 outputs 7 print $ a;?>

Since building an object network pointing to each other is the basis of all object-oriented design patterns, this improvement is of great significance. when reference allows more powerful object-oriented applications, PHP treats objects and other types of data in the same way, causing great pain for developers. as any PHP4 programmer will tell you, applications will suffer from WTMA (Way Too Many Ampersands &) syndrome. if you want to build a practical application, you will feel extremely painful.

1

In the summer of 1997, we developed PHP 3. we have no plans to make PHP ready...

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.