Chapter 1. Introduction

PHP 4 is a wildly popular web programming language. Web servers on over 15,000,000 domains support PHP. PHP is the most popular Apache module by almost a 2-to-1 margin. But if PHP's so great, why do we need PHP 5?

Well, PHP 4 isn't perfect. While it makes developing web applications quick and easy, it's occasionally weighted down by its legacy baggage. This makes tackling some problems unnecessarily difficult.

In particular, PHP's version of object-oriented programming (OOP) lacks many features, the MySQL extension doesn't support the new MySQL 4.1 client protocol, and XML support is a hodgepodge.

Fortunately, PHP 5 improves on PHP 4 in three major areas:

  • Object-oriented programming

  • MySQL

  • XML

These items have all been completely rewritten, turning them from limitations into star attractions. While these changes alone warrant a new version of PHP, PHP 5 also provides:

  • SQLite for an embedded database

  • Iterators

  • Error handling using exceptions

  • Streams

  • SOAP

Some of these features, such as iterators and exceptions, are available only due to fundamental changes in PHP's core. Others, such as streams and SQLite, are PHP 4.3 features that have matured into prime-time use in PHP 5.

This book shows you how to take advantage of these new features in your applications. Additionally, it places a special emphasis on not just telling you what's new, but showing you how and why it's new.

Whenever possible, there's a direct comparison between the PHP 4 method of solving a task and the PHP 5 solution. The PHP 5 way is frequently shorter, more elegant, and provides you with greater flexibility. The before-and-after examples demonstrate in clear code what's better about PHP 5 and provide you with concrete examples to ease the transition from PHP 4 to PHP 5.

This chapter serves as a dual introduction to both PHP 5 and Upgrading to PHP 5. It begins with a brief history of PHP that provides the motivation behind PHP 5. The next section provides a short description of all the major new features of PHP 5 and, at the same time, explains how the book is organized. This chapter ends with a discussion of how to install and configure PHP 5.