Buy me a Coffee
Web 2.0 Training
 
headermask image

Random Header :: Unpredictably Exciting

Sneak Peek at PHP 6

Taking a look at PHP 6 PHP Logo

 

While most web hosts are still in the PHP 4 era, the PHP developers are already planning and working on PHP 6. Lets have a look at whats been keeping them busy.

Unicode support

When youre 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 youre using, but with a little help of Apaches .htaccess file, you only have to make that decision once. However, if youre 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 whos using it in his application, but sometimes the developer is not even aware hes using it.

Im, of course, talking about the register_globals [php.net], magic_quotes [php.net] and safe_mode [php.net] 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. In case youd like to learn more about the possibilities of namespaces, I find this C++ tutorial [cplusplus.com] about namespaces quite useful.

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.

Becoming PHP 6 Compatible

In a new post on ‘Making the Web blog’, there’s a new post that talks about preparing your code for PHP6 when it comes around. “If you want to make use of PHP 6 when it comes, you’re going to have to write your new scripts so they are compatible, and possibly change some of your existing scripts. To start making your scripts PHP 6 compatible, I’ve compiled a list of tips to follow when scripting.” The list of tips has five entries:

  • Don’t use register_globals.
  • Stop using magic_quotes.
  • Don’t Register Long Arrays.
  • Preg instead or ereg.
  • Don’t initiate objects with the reference operator.

If you liked my post, feel free to subscribe to my rss feeds

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*