PHP 5.5 New Features
PHP 5. 5. 0 has become released, bringing with it tons of new features and steps. TechRepublic has rounded up 10 upgrades that web developers should check in the new release.
- Generators are available
Generators provide a simple approach to iterate through data without needing to write a class implementing this Iterator interface.
Just like another function a generator is defined while using the function keyword, but unlike a usual function that just returns an end result once, a generator can send back several results as needed using this yield keyword.
A generator means that you can iterate over a set of data having a foreach loop without needing to make an array in memory. The lack to create an array lessens memory usage and processing time period.
- Finally keyword added
The addition on the "finally" keyword refines the way that PHP refers to exception handling.
Like other high level languages PHP means that you can wrap code in an aim to catch block. Any exception that is certainly thrown by code within the try block will likely be passed to code within the catch block for being handled.
The finally keyword means that you can define a block of value, to be placed after this catch block, that will regularly be executed after the try in addition to catch blocks, regardless of no matter if an exception was thrown.
- New password hashing API
The new password hashing API means that you can use one line of code to come up with a salted password hash applying bcrypt.
The current default encryption formula used is bcrypt, although it is expected to change as completely new and stronger algorithms are included in PHP.
It is recommended to store the spark a database column that can grow beyond 60 characters.
Array in addition to string literal deferencing added
Both array and string literals is now able to be dereferenced directly to admittance individual elements and characters.
- Much easier class name resolution
The class keyword is now able to be used to retrieve the fully qualified name of any class, including thenamespace it is placed within.
- Empty() function accepts expressions
The empty() function, used to view whether a variable is empty or maybe a value equals false, can now be passed a manifestation and determine whether the changing that expression returns is clear.
- Support for the Zend Optimiser+ opcode cache added
The Zend Optimiser+ opcode cache has become added to PHP as the revolutionary OPcache extension.
OPcache improves performance of scripts by removing your need for PHP to load and parse scripts each time a request is made. It defines this by storing precompiled screenplay bytecode in shared memory.
- foreach loops support the list() construct
Values insides nested arrays is now able to be assigned to variables having a foreach() loop and thelist() assemble.
- New features included in GD library
PHP's GD extension for creating and manipulating graphics has gained new capabilities. Like for example , flipping support using the completely new imageflip() function, advanced cropping service using theimagecrop() and imagecropauto() functions, and WebP read and write support ,when using the imagecreatefromwebp() and imagewebp() functions.
- foreach loops currently support non-scalar keys
When iterating with the array using a foreach hook , element keys are now able to get a non-scalar value, that is a value in addition to an integer or a sequence.