• Your Cart is Empty
  • Cart
  • Log In

PHP 6 Preview

It's quite hard to find detailed information about the upcoming new revision of the PHP programming language - PHP 6. In this article, we intend to fill this gap, giving you detailed information on what the new PHP version will feature as improvements and changes.

PHP 6 Overview

When you are faced with the task of creating a website, one programming language comes to mind - PHP. For some years now it has been the leading programming language for web based applications and the PHP developer team is constantly working on providing new functionalities and improvements to the core of the language. Since PHP 3, which was the first version to provide really advanced functionality and make PHP a major player in the Programming Languages scene, the PHP Team has gone a long way, introducing PHP 4 and PHP 5. Both versions included major upgrades to the core of the language, in order to facilitate the users in creating their sites and give more and more possibilities to the coder.

The 6th revision of the PHP code will provide several long awaited improvements and upgrades. But the most major news about PHP 6 is that the PHP Team has finally decided to break away from all the deprecated code, still left over from PHP 3, such as the register_globals, in order to inspire better coding practices in all of the PHP users. We have prepared a short list of what will be introduced in the new PHP version, so scroll down to check it out.

Unicode Support

When building a website, you seldom have to worry about the encoding. You only have to specify the encoding you are using for the visitor, but even this is a problem you have to worry about only once, since the .htaccess file can be of a great help here. But, when you are dealing with a web based application, the character encoding can become a serious problem. This is why, the PHP developer team has incorporated the Unicode support - now PHP will be able to automatically decode both the input and output of the script, so that both the original database and the visitor receive the correct information, eliminating the need of having any extra functions or plugins to handle this task.

Alternative PHP Cache

The cache is a great way to improve the speed of an application or a script and there has been a large user demand for this to be included in the programming language. And, when there is a demand, there is always someone to meet this demand - the result is the Alternative PHP Cache. However, in the 6th revision of the PHP language, the developer team has finally decided to include this functionality in the core, so now APC (Alternative PHP Cache) is the default caching module for PHP.

Here are some examples of how APC can be used:

Caching a variable in the data store

<?php
$bar = 'BAR';
apc_store('foo', $bar);
?>

Fetch an already stored variable from the cache:

<?php
$bar = 'BAR';
apc_store('foo', $bar);
var_dump(apc_fetch('foo')); // Will output : BAR
?>

Delete a stored variable from the cache:

<?php
$bar = 'BAR';
apc_store('foo', $bar);
apc_delete('foo');
?>

Object Orientated (OO) Functionality

One of the long awaited changes in PHP 5 was the immensely improved OO Functionality. PHP 6 is set to go on even further, including “namespaces” in the new PHP core. If you are familiar with XML or C++, you probably know what namespaces are, but for our readers who are hearing this for the first time, namespaces will allow you to have several functions, objects and variables in one group, so that the same objects, variables or functions can be used later on, but with a different functionality. Here is an example, of how namespaces work (note: the example uses the C++ syntax, since PHP 6 is yet to be officially released):

"
namespace PHPnamespace
{
int z,x
}
"

In this case, the variables "z" and "x" are grouped together in a namespace, labeled "PHPnamespace". To access them outside the namespace, we have to call them, using the namespace syntax:

"
PHPnamespace::x
PHPnamespace::z
"

This way, we are free to use the "x" and "z" variables several times in the same file.

Changed Extensions

PHP, as a programming language, is a combination of extensions put together. When the extensions change, so must the whole language. For example, in PHP 5 we had the XML Reader, a great extension for reading XML files. In the 6th revision, a new extension will be added - XML Writer, which will allow the hassle free management of XML files, using just the PHP core, without the need of adding additional modules.

Another extension, which is going through changes, is the "mime_magic" extension. It will be removed from the PHP core and the very useful file_info extension will take its place as a default media type detection application.

Another change is the move of the "ereg" extension away from the core. It has been replaced with the PCRE (preg_match, etc.) extensions, since according to the PHP developers, "ereg" was causing some problems.

Things removed from PHP 6

PHP has been around for very long and this has lead to some bad practices and negative effects. At the moment, PHP 5 is still using deprecated code from the PHP 3 days, and PHP 3 was released back in 1998. In an effort to clean up the code, the PHP developers will exclude several things from the new release:

register_globals
magic_quotes
safe_mode

These were available for modification via the php.ini file in PHP 5, but in PHP 6 they will be completely removed.

Other things, which were also labeled as deprecated, such as register_long_arrays, zend.ze1_compatibility_mode, $HTTP_COOKIE_VARS, Freetype 1 and GD 1 support, will be removed as well. All of them will not be present in the PHP 6 releases.