See how PHP 5 compares to PHP 4 in this brief introduction to the language and learn what features have led PHP to be installed on over 15 million domains. (From the book, Beginning PHP 5 and MySQL: From Novice to Professional, by W. Jason Gilmore, ISBN: 1893115518, Apress, 2004.)
Version 5, in beta at the time of this writing, is sizing up to be yet another watershed in the evolution of the PHP language. Although previous major releases had enormous numbers of new library additions, version 5 contains improvements over existing functionality and adds several features commonly associated with mature programming language architectures.
Vastly improved object-oriented capabilities: Improvements to PHP’s object-oriented architecture is version 5’s most visible feature. Version 5 includes numerous functional additions such as explicit constructors and destructors, object cloning, class abstraction, variable scoping, interfaces, and a major improvement regarding how PHP handles object management. Chapters 6 and 7 delve into the subject of object-oriented PHP.
Try/catch exception handling: Devising custom error-handling strategies within structural programming languages is, ironically, error-prone and inconsistent. To remedy this problem, version 5 now supports exception handling. Long a mainstay of error management in many languages, C++, C#, Python, and Java included, exception handling offers an excellent means for standardizing your error reporting logic. This new and convenient methodology is introduced in Chapter 8.
Improved string handling: Prior versions of PHP have treated strings as arrays by default, a practice indicative of the language’s traditional loose-knit attitude towards datatypes. This strategy has been tweaked in version 5, in which a specialized string offset syntax has been introduced, and the previous methodology has been deprecated. The new features, changes, and effects offered by this new syntax are discussed in Chapter 9.
Improved XML and Web Services support: XML support is now based on the libxml2 library, and a new and rather promising extension for parsing and manipulating XML, known as SimpleXML, has been introduced. In addition, a SOAP extension is now available. In Chapter 18 I'll introduce SimpleXML and the new SOAP extension, and also demonstrate a number of slick third-party Web Services extensions.
Native support for SQLite: Always keen on choice, the developers have added support for the powerful yet compact SQLite database server. SQLite offers a convenient solution for developers looking for many of the features found in some of the heavyweight database products without incurring the accompanying administrative overhead. I introduce SQLite and PHP’s support for this powerful database engine in Chapter 20.
A host of other improvements and additions are offered in version 5, many of which I’ll introduce as relevant throughout the book. When practical, I’ll be sure to introduce these improvements as the book proceeds.
As the release of PHP 5 draws near, PHP’s prevalence is at a historical high. At press time, PHP has been installed on more than 15 million domains (Netcraft, http://www.netcraft.com/). According to E-Soft, Inc. (http://www.securityspace.com/), PHP is by far the most popular Apache module, present on over 50 percent of all Apache installations.
So far, I’ve only discussed version-specific features of the language. Each version shares a common set of characteristics that play a very important role in attracting and retaining a large user base. In the next section, you’ll learn about these foundational features.