2/12/13

The Zend Engine


When PHP 3 was written, an entirely new parser was created from the ground up. The introduction of PHP 4 represented a similar revolution in the code base. Zend is a scripting engine that sits below the PHP-specific modules. It was optimized to ensure massively improved performance and extensibility.

PHP 5 brings new fundamental improvements with the introduction of the Zend Engine 2. We have already touched on the great change ushered in by ZE2. The engine provides significantly enhanced support for object-oriented programming. For the first time, objects and object-oriented design lie at the heart of PHP, making it an even more suitable platform for large enterprise applications.

Performance

Because of the powerful Zend engine, PHP shows solid performance compared with other server scripting languages, such as ASP, Perl, and Java Servlets, in benchmark tests. To further improve performance, you can acquire a caching tool (Zend Accelerator) from http://www.zend.com/; it stores compiled code in memory, eliminating the overhead of parsing and interpreting source files for every request.

Portability

PHP is designed to run on many operating systems and to cooperate with many servers and databases. You can build for a Unix environment and shift your work to NT without a problem. You can test a project with Personal Web Server and install it on a Unix system running on PHP as an Apache module.

What's New in PHP 5


PHP 5 introduces numerous new features that will make the programmer's life more interesting. Let's take a quick look at some of them. If they don't make sense to you now, don't worry, we cover all these features in detail in this book:

  • PHP has new integrated for support for XML. The various functions and classes provided to handle XML in different ways all now use the same underlying library (libxml2). This should make XML features more stable and interoperable.
  • The SQLite SQL library is now bundled with PHP, together with all the functions you need to work with it.
  • PHP now supports private and protected methods and properties in classes.
  • PHP supports class constants.
  • Objects passed to functions and methods are now passed by reference. That is, a reference to an object is passed around your script rather than copies of objects. This significantly reduces the likelihood of bugs in object-oriented code.
  • PHP supports static methods and properties, making more advanced object-oriented designs possible.
  • Methods can now be declared to require particular object types.
  • The comparison operator (===) now checks that two references point to the same object. Previously, it was hard to test objects in this way.
  • PHP now supports abstract classes and interfaces.
Many of these improvements are due to some fundamental changes under the hood.