Section 15--The Development of Zend Engine -- Classes and Objects in PHP5 [15_PHP Tutorial

WBOY
Release: 2016-07-13 16:57:55
Original
1003 people have browsed it

/*
+-------------------------------------------------- ----------------------------------+
| = This article is read by Haohappy<>
| = Notes from the Chapter Classes and Objects
| = Translation + personal experience
| = Please do not reprint to avoid possible unnecessary trouble, thank you
| = Welcome criticisms and corrections, and hope to make progress together with all PHP enthusiasts!
+-------------------------------- --------------------------------------------------+
*/
Section 15--The Development of Zend Engine
In the last section of this chapter, Zeev discusses the object model brought by Zend Engine, specifically mentioning its relationship with previous versions of PHP
When we developed PHP3 in the summer of 1997, we had no plan to make PHP object-oriented. There were no ideas about classes and objects. PHP3 was a purely procedural language. . However, support for classes was added to the PHP3 alpha version on the night of August 27, 1997. Adding a new feature to PHP only required minimal discussion at that time, because there were too few people exploring PHP at that time. So from August 1997 Since then, PHP has taken the first step towards an object-oriented programming language.
Indeed, this is only the first step. Because there are very few relevant ideas in this design, the support for objects is not strong enough. In this version Using objects is just a cool way to access arrays. Instead of using $foo["bar"], you can use the prettier $foo->bar. The main advantage of the object-oriented approach is through member functions or method to store functionality. Example 6.18 shows a typical code block. But it is not much different from the approach in Example 6.19.
Listing 6.18 PHP 3 object-oriented programming Object-oriented programming in PHP3
class Example
{
var $value = "some value";
function PrintValue()
{
print $this->value;
}
}
$obj = new Example();
$obj->PrintValue();
?>
Listing 6.19 PHP 3 structural programming PHP3 Structure in PHP3 Programming
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);
?>
Above we write two lines of code in the class, or pass the array explicitly to the function. But considering that there is no difference between these two options in PHP3, we can still use the object model as just a "syntactic gloss" to access the array.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631481.htmlTechArticle/* +--------------------- -------------------------------------------------- --------+ | = This article is for Haohappy reading Core PHP Programming | = Notes from the Chapter Classes and Objects | = Translated as...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!