日期:2014-04-04  浏览次数:20447 次

翻译:深空
作者:Andi Gutmans, Stig Bakken, and Derick Rethans
不得擅自转载。

Introduction [绪论]
Language Features [语言特性]
• New Object Oriented model [新的面向对象模型]
• New Object Oriented Features [新的面向对象特性]
• Other New Language Features [其他新的语言特性]
General PHP changes [PHP 变化概要]
• XML and Web Services [XML 和 Web 服务器]
• New MySQLi (MySQL Improved) extension [新的 MySQLi (改良的 MySQL) 扩展
]
• SQLite extension [SQLite 扩展]
• Tidy extension [Tidy 扩展]
• Perl extension [Perl 扩展]
• Other New Things in PHP 5 [其他 PHP5 新事物]
Summary [总结]




The best way to be ready for the future is to invent it. (John Sculley)
为未来作好准备的最好方法就是创造它。 (John Sculley)

Introduction [绪论]
Only time will tell if the PHP 5 release will be as successful as the releases
of its two predecessors (PHP 3 and PHP 4). The new features and changes aim t
o rid PHP of any weaknesses it may have had and make sure that it stays in the
lead as the best web scripting language on the globe.
只有时间能够证明 PHP5 是否和他的两个前辈(PHP3 和 PHP4)一样成功。新的语言特性和
改变的目的是为了消除 PHP 可能已经具有的弱点, 和证实它作为全球最优秀的网页脚本
语言所处的领先地位。

This book covers PHP 5 and its new features in great detail. However, for thos
e of you familiar with PHP 4, and are eager to know what is new in PHP 5, then
this chapter is for you.
这本书囊括了 PHP5 和它的新特性的详细描述。然而,作为 PHP4 的亲密好友的你都渴望
知道 PHP5 究竟做了哪些更新,那么,这一章就是为你准备的。

The chapter will cover:
本章将包括:

The new language features [新的语言特性]
News concerning PHP extensions [关于 PHP 扩展的新消息]
Other noteworthy changes [其他值得注意的改变]

Language Features [语言特性]
New Object Oriented model [新的面向对象模型]
When Zeev Suraski added the object-oriented syntax back in the days of PHP 3,
it was added as "syntactic sugar for accessing collections". The object-orient
ed model also had support for inheritance and allowed a class (and object) to
aggregate both methods and properties, but not much more. When Zeev and Andi r
ewrote the scripting engine for PHP 4, it was a completely new engine, running
much faster, much more stable and with many more features. However, the objec
t-oriented model first introduced in PHP 3, was barely touched.
当 Zeev Suraski 在 PHP3 时期添加面向对象语法的时候,它被作为 "syntactic sugar
for accessing collections" 添加。该面向对象模型也支持继承和允许类(或对象)聚合
方法和属性,但没有更多的特性了。当 Zeev 和 Andi 为 PHP4 重写脚本引擎的时候,它
是一个完全新的引擎,运行更快、更稳定,和集合了更多的特性。然而,面向对象模型首
次在 PHP3 中引入,却极少涉及。

Although the object model had serious limitations it was used extensively arou
nd the world, often in very large PHP applications. This impressive use of the
OOP paradigm with PHP 4 despite its weaknesses led to it being the main focus
for the PHP 5 release.
虽然,对象模型已经严重限制了它在世界范围上的广泛使用--常常是非常大型的 PHP 应
用程序,但是这个给人印象深刻的面向对象程序设计范例的应用和 PHP4 的缺点导致它成
为 PHP5 发布版本的主要焦点。

So what were some of the limitations in PHP 3 & 4? The biggest limitation (whi
ch led to further limitations) was the fact that the copy semantics of objects
were the same as for native types. So how did this actually affect the PHP de
veloper? When you’d assign a variable (that points to an object) to another v
ariable, a copy of the object would be created. Not only did this impact perfo
rmance but it usually also lead to obscure behavior and bugs in PHP 4 applicat
ions because many developers thought that both variables would be pointing at
the same object which wasn’t the case. They were pointing at separate copies
of the same object, changing one would not change the other.
那么,PHP3 & PHP4 的局限性在哪里呢?最大的局限性(这导致更大的局限)是,事实上
对象的拷贝和原始对象一样,因此这实际上影响了 PHP 的开发。当你将一个变量(它指向
一个对象)赋值给另外一个变量的时候,这个对象的一个拷贝将被创建。在 PHP4 的应用
程序里这样做不仅对执行产生影响,而且通常导致模糊的行为和错误。因为许多开发者认
为这两个变量指向相同的对象(事实并不如此)。它们分别指向了这个对象的两个拷贝, <