To understand why PHP 5 came to exist, it's necessary to quickly review the evolution of PHP as a language.
When Rasmus Lerdorf created PHP back in 1995, it wasn't even called PHP?his Personal Home Page/Forms Interpreter language was known as PHP/FI. At the time, PHP/FI's main focus was solving small-time web tasks: guest books, hit counters, and basic forms processing. Its major benefit was its simplicity; PHP/FI made it easy to handle all the messy tasks thrown at a web developer. Additionally, it's C-like syntax was already understood by many programmers.
Over the next two years, PHP/FI gradually grew in popularity. However, by 1997, PHP/FI was already showing its age. As the Internet gathered steam, programmers began to create more complex applications, such as e-commerce shopping carts. PHP/FI's quirks and limitations hindered development. It was too slow and was missing some basic features, such as for and foreach loops.
These problems caused Zeev Suraski and Andi Gutmans, of Zend fame, to begin work on a new version of PHP/FI. This version, which became PHP 3, solved many difficulties faced by PHP/FI developers while remaining true to the essential nature of PHP/FI.
In particular, PHP 3 was faster and more efficient than PHP/FI. The new parser also provided the opportunity to iron out some language oddities, making PHP more consistent. PHP 3's other major advance was an easy-to-use extension API. Developers from all over contributed extensions to PHP, effectively turning PHP from a programming language into an entire web development environment.
PHP 3 retained PHP/FI's procedural syntax, but it also introduced a very simplistic object-oriented syntax. Originally the result of a weekend hack, developers flocked to objects, much to the surprise of Zeev and Andi. Unfortunately, PHP 3 was ill-equipped to provide all the object-oriented features developers demanded.
A few months after PHP 3 went final in June of 1998, work started on PHP 4. Again, the problem was speed. The new extension infrastructure provided the opportunity to create larger and more complex web sites than ever imagined. In the words of Alan Greenspan, "irrational exuberance" was at hand.
While PHP 4 provided yet another burst of power, its secondary objective was backward compatibility. There was a strong emphasis on not breaking PHP 3 scripts under PHP 4. As a result, beefing up the core language was not a main focus of PHP 4. PHP 4 was released in May 2000, almost two years after PHP 3.
A lot has happened over the last four years. Perl may be the "duct tape of the Internet," but PHP is the real glue that holds the Web together. However, PHP still faces challenges. The problems of performance and flexibility have long been conquered, but now PHP is under attack from the twin foes of Java and C#.
Over the past 10 years, Java and C# have introduced advanced object-oriented programming concepts to web development. Yet in many ways, despite all the improvements, PHP 4.3 is still the same procedural language that Rasmus wrote a decade ago. PHP 5 finally grants developers their wish, providing a full set of object-oriented features.
These features, which are discussed in Chapter 2, allow developers to more easily develop large-scale applications without resorting to the cumbersome workarounds necessary in PHP 4. They also let you write cleaner code that's less error-prone and more maintainable.