一些杂谈
首先是本文写作的初衷。我拿到关于Zend Engine 2.0的设计蓝图文档已经有一段时间了(现在大家也可以去参考资料中的地址下载回来看看),看完之后就有了写一篇评论的冲动--因为根据文档的描述下一代的PHP将是一种更符合现有面向对象开发习惯的语言,至少是被更多的赋予了面向对象特性。但是随之带来的问题就是对于PHP这样一个以Web快速开发为初始目标的语言是否值得将自己修饰得面面俱到?这个问题看来是需要一些评论文章来讨论的,我也很愿意提出自己的观点。但是后来一些繁忙的事情就将这个冲动一点点又打回了肚里,直到最近一段时间又想起,于是再拜读几遍设计蓝图文档,遂有此文。(刚拿到这份英文文档的时候我还有将这份设计蓝图文档翻译到中文的打算,但是考虑到一是并非最终蓝图,二是大家都应该培养直接阅读原文的习惯,三是翻译总是不可避免会带来一些晦涩的地方,于是暂时作罢。不过写成此文的时候,还是决定"冒险"翻译一次,不能准确达意之处还请各位不吝指正。)
其次是对本文讨论焦点的解释--在这篇评论中我将主要针对将来的PHP中得以大大加强的面向对象特性进行评述。如果你是PHP的开发者,那么我猜想你应该了解一些PHP语言中的面向对象特性;但是由于一般PHP用于"极端快速开发环境"(这是我自己生造出的一个词语,表示进行一些以客户为导向的网站开发的情况,特点就是工期非常短且客户要求不甚明确),所以真正大量使用其对象特性的开发者以及开发项目并不是很多;另外,现有PHP对象模型相对C++和Java的弱势,也限制了这方面特性的使用。不过在PHP的将来版本中,修改重点就在于语言中的面向对象模型,完善现有版本中许多不良的特性并加入其他特性。因此讨论PHP的未来面貌就集中在讨论PHP的面向对象特性方面。
好了,让我们步入正题,看看Zend Engine 2.0的新特性。
归纳Zend Engine 2.0设计蓝图(草稿)
从设计蓝图(草稿)中可以非常清楚的看出下一代Zend Engine是以新的面向对象模型为基础的。如果你曾经使用过现有PHP 4的面向对象特性,那么也许会在找到一点点Java或者C++的感觉的同时觉得有些别扭--不但是在面向对象语法的匮乏上,而且有时会得到意想不到的运行结果--这一切都是因为在现有的支持PHP 4的Zend Engine 1.0中不那么优雅的面向对象模型造成的。
简单说来,下一代的Zend Engine将向Java靠拢,大量借鉴其面向对象模式。从改进特性的类型来看,应该可以分为三类:第一类是对现有面向对象模型的改进和加强,其中包括对构建器和析构器的定义,增加的私有成员变量、静态成员变量、多重继承、过载等面向对象特性;第二类是对于控制流程的修改和增删,比如增加了形如try/catch/throw违例处理机制;第三类是关于函数的修改和增删,比如对于字符串偏移量的增加函数。(对于每一类改进的详细情况,可以查阅参考资料中所列文档。)由此可以看出,通过第一类和第二类的改进,PHP正在逐步将自己改良成一种具有面向对象特征的语言。
不过问题恰恰就产生于此:
从积极的方面来说,如今的编程世界中更加欢迎具有面向对象特征的语言(即使语言本身并不构建于面向对象基础之上,也可以通过增加定义的对象等手段使得该语言不至于落在潮流之后)--从这一意义上说,Zend Engine 2.0使得PHP对面向对象的支持将从现在的试探性接触转变为将来的全面拥护,看来更加符合编程语言发展的潮流;另外,在构建企业级应用(这也是PHP现在经常被人指责之处)之时,采用面向对象的方法建模和实现已经是事实上的标准,而PHP的这一改进也许会迎合这一需要,解决语言自身在这方面的薄弱之处。
从消极的方面来说,为开发者奉献一个更加类似Java的新版PHP似乎没有什么意义。PHP被广泛应用的原因,除了源码公开和跨平台等之外,适应互联网站构建的简单、快速的web编程(在现在的程序开发中占有很大的比重)特点恐怕也是重要的一点。极短的学习时间、友好的语言风格(特别是如果你对C比较熟悉)和大量扩充类库函数,足以证明其强大;但是如果将这样的语言的下一版本改造成类似面向对象的语言,不但会使原有的大量开发者在短时间内无所适从,而且非常不利于吸引新的开发者加入--既然有Java这样的语言,何必去学习PHP呢?

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Laravel simplifies HTTP verb handling in incoming requests, streamlining diverse operation management within your applications. The method() and isMethod() methods efficiently identify and validate request types. This feature is crucial for building

The Storage::download method of the Laravel framework provides a concise API for safely handling file downloads while managing abstractions of file storage. Here is an example of using Storage::download() in the example controller:


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
