PHP 6 Review

Unicode support

When you're creating a website, you hardly have to think about the character encoding. You only have to decide how you tell the user agent what encoding you're using, but with a little help of Apaches .htaccess file, you only have to make that decision once. However, if you're building an application, the character encoding might become a problem. Thats where PHPs new Unicode support comes in handy. With its support, PHP can automatically encode and decode the in and output of the script making sure both the database and the user agent receive the encoding they need without the need of any extra functions for the encoding conversion.

The big cleanup

PHP is already being used for a long time, creating a big user base, but also a lot of bad habits. Bad habits often result in slow scripts or even security holes. But these bad habits are not always the cause of the developer. Of course, he (lets just assume were dealing with a stereotype developer here for simplicity's sake) is the one who's using it in his application, but sometimes the developer is not even aware hes using it.

Im, of course, talking about the register_globals, magic_quotes and safe_mode functions. These three functions are hell for every PHP programmer so Im sure everyone will be happy to hear that these functions will disappear in PHP 6.

In other related cleanup news, register_long_arrays and the long versions of the super globals like $HTTP_COOKIE_VARS are also gone in PHP 6. Same goes for zend.ze1_compatibility_mode which dealt with the backwards compatibility of PHP 5 classes.

Alternative PHP Cache

Caching is a very good way to improve the performance of an application. Thats why there was a large demand for a good opcode cache in the default distribution of PHP. And when theres a demand, theres probably also a person or a group to meet that demand. The result is APC [php.net]: Alternative PHP Cache. Of course, APC was already available a long time ago (01-07-2003), but the PHP developers have decided to include this extension in the core as the default caching framework.

OO Functionality

The improved OO model was probably the biggest improvement to PHP in version 5.0. PHP 6 tries to improve this even further by adding namespaces. If youre familiar with XMLs namespaces or maybe C++, you will probably have an idea of how namespaces work. If not: Namespaces can group variables, functions or objects under a certain name. This allows the developer to use the same name for a variable, function or object multiple times.

Changes to the extensions

PHP is basically a collection of extensions which are all put together to form what we have now. However, these extensions change and so does the collection. Take, for instance, the XML Writer extension. A great extension to write XML files. Its brother, XML Reader, was already added and enabled in the core distribution in PHP 5.1, and now XML Writer will follow its example in PHP 6, forming a great duo to easily work with XML files.

Another change in the core distribution is the removal of the ereg regular expressions library which is going to be made an extension. ereg is currently used as an competitor of PCRE (preg_match, etc.), but apparently its causing some problems. Therefore, the developers decided to remove it from the core and make it an extension.

Yet another change we see is the Fileinfo extension which will be dealing with media type detection. At the moment, media type detection isnt very good in PHP. We have the mime_magic extension, but that isnt really reliable. So in PHP 6, the Fileinfo extension will take over mime_magics place and become part of the core while mime_magic will be moved from the core and made into an extension.

So we have seen quite some interesting changes so far. To me, PHP 6 doesn't really look like a massive feature update, but more as a big cleanup while improving a lot of existing functions along the way. And I think thats good! Im working with PHP on an almost daily basis and looking at the things noted above, Im only seeing improvements. So hopefully developers of popular applications like phpBB will make their applications work properly on PHP 5 making it easier for web hosts to switch their servers to PHP 5. But at the current state of PHP 5 support, I dont see PHP 6 becoming widely adopted if it were released today. So hopefully this will change by the time PHP 6 will be released.

For all the planned changes to PHP 6 (including the ones I noted above), check out these meeting notes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <b> <i> <p> <br> <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.