PHP 5.5.0 Released
Written by Ian Elliot   
Friday, 21 June 2013

PHP has come a long way since it was first released and now we have version 5.5 with some interesting sophisticated new features.

PHP 5.5 is ready for you to download and install and the source code is ready for you to read. For a decimal point upgrade there are a lot of new features. 

From the language point of view, PHP has acquired some "modern" features. You can now make use of generators to implement iteration over custom data. PHP introduces the yield command, which is familiar from other languages.

A generator is just a standard function with a yield value command in place of a return. When a generator is first called it returns an iterator which can be used in a foreach loop. When used in a foreach loop the generator function is called and returns the value specified in the yield as the value used in the loop. When the loop repeats the generator is resumed at the instruction following the yield so providing a sequence of values. 

For example:

function genseq() {
 yield $i;
 yield $i;
 yield $i;

generates the sequence 1,6,27 and can be used in a foreach loop as 

$generator = genseq();
foreach ($generator as $value) {
    echo "$value\n";

or more simply

foreach ($genseq() as $value) {
    echo "$value\n";

There are a lot of other things to learn about yield and the way it can be used to create sophisticated iterative solutions and manage asynchronous calls as a form of continuation passing.

The addition of generators is by far the biggest change to the core language, but it is worth noting that PHP finally has finally.

PHP programmers have been waiting of the finally clause within exceptions for almost as long as I have been waiting to write the "finally finally" sentence. It adds a structure that has been missing from PHP for too long.  Code in a finally block is executed no matter what - i.e. irrespective of whether the code in the try block works or causes an exception. It provides an opportunity to clean up whether the code works or it fails. 

Another important change is the new password hashing API. Given how important security is, the fact that it now takes one line to create a salted password;


and one line to verity it:


is a great advantage.

Crypto doesn't get any easier.

Under the cover the new API uses Bcrypt which provides a very secure hash which should keep passwords safe provided they are long enough.

There are a number of other minor additions to the language:

  • support for list() in foreach
  • constant array/string dereferencing
  • ext/intl improvement
  • support for using empty() on the result of function calls and other expressions

A big change to the operating environment is the addition of Zend Optimizer+, which was open sourced earlier in the year. This is now part of the core distribution, OPcache, and it improves the bytecode generation and caches code in shared memory. 

Of course, with any change to a language there are likely to be incompatibilities. The only ones listed are the loss of the PHP logo GUIDs whatever they were and the change to case sensitive matching. Previously this was locale-specific, but now it applies independent of locale. 

It might also affect a few users that Windows XP is no longer supported. However, there can't be many Windows XP systems acting as web servers and so the number affected should be small. 

Finally, if you hurry you have the opportunity to add the first comments to some of the PHP documentation pages, which at the time of writing look unusually bare!





More Information

Announcement of 5.5.0 

New features and incompatibilities

Related Articles

Zend Optimizer+ For PHP?

PHP 5.5 Beta1 Released        

Zend Survey of PHP Developers       




To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, FacebookGoogle+ or Linkedin,  or sign up for our weekly newsletter.



kotlin book



or email your comment to:


Rust Foundation Announces Safety-Critical Consortium

The Rust Foundation, the nonprofit organization dedicated to supporting and sustaining the Rust programming language, has announced a Safety-Critical Rust Consortium along with industry partners inclu [ ... ]

Gemini Offers Huge Context Window

Google has announced a range of improvements to Gemini, along with the release of Gemma 2. The first enhancement is access to a 2 million context window for Gemini 1.5 Pro, backed up with context cach [ ... ]

More News




Last Updated ( Friday, 21 June 2013 )