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:
generates the sequence 1,6,27 and can be used in a foreach loop as
or more simply
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:
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 InformationNew features and incompatibilities Related Articles
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
Comments
or email your comment to: comments@i-programmer.info
|
|||
Last Updated ( Friday, 21 June 2013 ) |