Some Major Improvements in PHP 5.5.0 to Help Web Developers

By Infinium On November 15, 2013

PHP 5.5.0 has arrived with a slew of new fixes and features. The new version shows marked improvement on the previous launches. This article details some most important improvements of the new release to help the web developers in multiple ways. One major difference is support for Windows 2003 and XP has been dropped in 5.5.0.

Generators are available

Generator offers a simple way to repeat the same data without requiring the developers to write a class through implementation of Iterator interface. Like other functions, a generator is also defined by a function keyword but unlike the normal functions which usually sends back a result only once, a generator can return as many results as required by using yield keyword. You can use a foreach loop to repeat a string of data without having to build up a block of array, which will reduce usage of memory as well as processing time.

‘Finally’ keyword added

‘Finally’ keyword addition refines the mode of how PHP deals with exception handling. Like many high level language, PHP enables you to cover up the code in a try and catch block. Any exception within the try block will be transferred to catch block code for handling. This ‘finally’ keyword lets the developers define a block of code, which is to be placed after the catch block and executed after try and catch blocks, no matter if an exception is was thrown or not.

Empty() function accepts an expression

Empty() function is used to determine if a variable is empty or contains a value equal to false. With the release of PHP 5.5.0, this function will now accept an expression and decide if the variable returned by the expression is empty.

Addition of Support for Zend Optimiser+ opcode cache

PHP 5.5.0 features another new addition – Zend Optimiser+ opcode cache. It is a new OPcache extension. OPcache makes improvement on script performance by removing any requirement for PHP to load and parse a script whenever it receives a request. This is done by getting precompiled script bytecode stored in shared memory.

GD library contains new features

PHP’s GD extension is now armed with another responsibility of creation and manipulation of images. These include imagecrop() and imagecropauto() functions for advanced cropping support, imageflip() function for flipping support and imagewebp() and imagecreatefromwebp() for WebP read and write support.

Foreach loops support non-scalar keys

When a foreach loop is used to iterate through an array, element keys can have a non-scalar value, which is other than a string or an integer.