2. Introduction
On 20-June-2013, PHP 5.5.0 rolled out by the
core development team. It consists to some
bug fixes as well as some new features.
3. Features included
Introduced “Generators” and “Coroutines”
Generators : It provides easy way to implement simple iterators such as
“foreach”. This implementation will save memory. Coroutines will help in
cooperative multitasking.
You can write a code to iterate a set of data without creating an array in
memory, mainly with the help of “yield” keyword.
function getValues() {
yield “iOS";
yield “Android";
yield “BlackBarry";
}
$stuff = getValues();
foreach($stuff as $thing) {
echo $thing . "n";
}
4. Features included
“finally” keyword is added
Now, a finally block can be written after the try, catch block.
This block will be executed regardless of whether an exception
has been thrown, and before normal execution resumes.
try {
echo ”Try Block” . "n";
} catch (Exception $e) {
echo 'Caught exception: ', $e-
>getMessage(), "n";
} finally {
echo “Finally.n";
}
5. Features included
A simplified Password hashing API is introduced
It provides an easy to use wrapper around “crypt()” for
creating and managing passwords.
No external library is required. No installation is required. No
configuration directives in php.ini
password_hash and password_verify are the functions to be
used.
6. Features included
Constant array/string dereferencing
Array and string literals can now be dereferenced directly to
access individual elements and characters
echo [abc, xyz, pqr][0];
// results abc.
echo „DHIRAJ‟[0];
// results D.
7. Features included
Scalar class name resolution added
With the help of “::class” keyword, you can get a string containing the fully
qualified name of the Class.
Particularly useful with namespaced classes.
namespace NS {
class ClassName {
}
echo ClassName::class;
//results NSClassName.
}
8. Features included
Now empty() can be used on any expression
empty() function can be called on not only variables
but function returns or any other arbitrary
expressions.
9. Features included
Non-scalar Iterator key support is added
The ability to iterate over an array of arrays and unpack the nested array
into loop variables by providing a ”list()” as the value.
$array = [[1, 2],[3, 4]];
foreach ($array as list($a, $b)) {
echo "A: $a; B: $bn";
}
result: A: 1; B:2
A: 3; B:4
10. Changes
MySQL extension:
This extension has been deprecated, so there will be
deprecated warnings on use of this extension. MySQLi
extension can be used in place of that.
Support for MySQL 5.6+ has been incorporated in various
ways.
11. Many of the bugs have been fixed in this
version. The complete change log can be
seen on
http://php.net/ChangeLog-5.php