Section 15th -- Development of the Zend Engine -- Classes and Objects in PHP5 [15

Source: Internet
Author: User
/*
+ ------------------------------------------------------------------------------- +
| = Read this article for Haohappy <Core PHP Programming>
| = Notes in the Classes and Objects chapter
| = Translation-oriented + personal experiences
| = Do not repost it to avoid unnecessary troubles. Thank you.
| = Thank you for your criticism and hope to make progress together with all PHP fans!
+ ------------------------------------------------------------------------------- +
*/
Section 15th -- Development of the Zend Engine
In the last section of this chapter, Zeev discusses the object model brought about by the Zend Engine, especially the differences between Zeev and the models in the previous versions of PHP.
When we developed PHP3 in the summer of 1997, we had no plans 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. in example 6.18, a typical code block is displayed. however, it is not very different from the practice in example 6.19.
Listing 6.18 PHP 3 object-oriented programming Object-Oriented programming in PHP3
<? Php
Class Example
{
Var $ value = "some value ";
Function PrintValue ()
{
Print $ this-> value;
}
}
$ Obj = new Example ();
$ Obj-> PrintValue ();
?>
Structured programming in Listing 6.19 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.

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.