LWN.net Logo

What's new in PHP 5?

July 21, 2004

This article was contributed by Joe 'Zonker' Brockmeier.

A little more than a year since the first beta was released, the final release of PHP 5 was announced last Tuesday. As is to be expected with a major version release, this release brings with it a slew of new features and improvements.

Most noteworthy in the new release is the Zend Engine 2.0, what one might call the core of PHP. The Zend Engine is responsible for parsing and executing PHP code, implements PHP's data structures, memory and resource management and more. With the 5.0 release, there are quite a few changes in the Zend Engine. No major version release would be complete without performance tweaks, and PHP 5 is no exception. This release includes a new memory manager, designed with muli-threaded environments in mind.

Naturally, PHP 5 includes some language changes. One interesting addition is the introduction of private and protected member variables. This allows PHP developers to decide whether or not they wish to make a variable visible to a class that extends a class the variable is extended in (protected) or set variables to be visible only to the class that they are declared in (private).

PHP 5 also introduces destructors for objects, something that was missing in PHP 4. (Constructors were present in PHP 4, but behaved differently.) This allows developers to define a destructor for an object that can perform a task when the last reference to an object is destroyed.

XML support has been beefed up in PHP 5. The XML extensions in PHP 5 are based on the Libxml2 library from the GNOME project. PHP 5 supports SAX, which was present in PHP 4, and adds support for the W3C DOM standard, XSLT and SOAP. The changes are covered in some detail in this article. There is also the SimpleXML extension.

Developers who use PHP in conjunction with MySQL will be interested in the MySQLi extension. This extension gives developers access to functions in MySQL 4.1.2 and above. This version supports prepared statements, SSL, transaction control and a number of other features present in MySQL 4.1 and above.

If MySQL isn't to your tastes, the SQLite extension is bundled with PHP 5. SQLite is a C library that implements a SQL database engine which does not require a separate SQL server. For lightweight installations or situations (such as shared hosting) where a PHP developer does not have access to MySQL or another SQL server, this may be of great interest. SQLite requires no configuration, implements much of SQL92 and supports databases up to 2 terabytes.

There are also quite a few new functions in PHP 5 that are worth looking into for PHP developers. The ChangeLog lists the new functions added in PHP 5, most of which (if not all) are already documented in the PHP Manual.

For more cautious PHP developers and users, PHP 4.3.8 was also released last Tuesday to address several security problems that have come to light since the release of PHP 4.3.7. If not upgrading to 5.0, users should be sure to upgrade to the 4.3.8 release.

In all, the PHP 5 release looks like a nice step forward for the PHP project. The changes to PHP 5 should inflict minimal, if any, pain on developers who have been developing on PHP 4.


(Log in to post comments)

What's new in PHP 5?

Posted Jul 22, 2004 16:35 UTC (Thu) by markc (guest, #4419) [Link]

A great upgrade to a popular language. What I find missing are examples of
how to take best advantage of the new features. There are some simple
examples and a few complex apps using PHP5 but nothing much "in the
middle" that really shows off the new OOP features in a comfortable
humanly parsable manner. I guess we have to wait awhile for some nice
tutorials to show up. Please, help, post some URLs to any good PHP5
tutorials or coding examples.

What's new in PHP 5?

Posted Jul 22, 2004 18:25 UTC (Thu) by dave (guest, #7) [Link]

There are some good tutorials at Zend's website. That's an obvious first place to start.

What's new in PHP 5?

Posted Jul 23, 2004 15:58 UTC (Fri) by tjw.org (guest, #20716) [Link]

The following is a link to an overview of the language changes with example code.

Changes in PHP 5/Zend Engine 2.0

Still no "standard" DBI equivalent?

Posted Jul 24, 2004 13:41 UTC (Sat) by topher (guest, #2223) [Link]

What I don't understand is why there seems to still be no "standard" equivalent to Perl's DBI. Why do we have to use completely different interfaces for every database we want to talk to?

Heck, here PHP5 is, touting the new MySQL support library, and also a new SQLite support library. . . and I'm left wondering why it is that they're not extolling the virtue of a standardized SQL access library, that can be used nearly transparently with SQLite, MySQL, PostgreSQL, Oracle, etc.

Having to write different PHP code to support different databases, or being forced to find your own database independant interface is just silly.

It's funny, most Perl applications that support a database can, with minimal work, support any database you want to use.

PHP, on the other hand, is usually MySQL, or nothing.

Here's a wake-up call, guys. A large number of people out there don't use MySQL, and don't plan to use it. Some of us actually *need* things that a true ACID compliant RDBMS offers, that MySQL doesn't. MySQL might work 5 years from now, but it doesn't do what I need now.

Oh, well. Nice to see PHP is still being developed. . . I'm going back to Perl, now.

Still no "standard" DBI equivalent?

Posted Jul 24, 2004 23:53 UTC (Sat) by tarvin (subscriber, #4412) [Link]

See PEAR DB for the "standard" database abstraction layer for PHP. There are others, perhaps most notably ADOdb.

By the way: Currently, there seems to be much discussion about database abstraction layers in general. See Lambda the Ultimate's discussions for just some of the opinions.

Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds