New features of PHP5.5. I read the new PHP5.5 features released by @ Xuan Mai blade today. However, there is no full translation. I would like to add it here to a complete article: www. php. netmanualzhmigration55. I have read the new PHP 5.5 features released by @ Xuan Mai. However, there is no full translation. I would like to add a little bit here and sort it into a complete article :)
Original article: http://www.php.net/manual/zh/migration55.new-features.php
1. generator
Php5.5YieldKeyword to support generators. Generators provides a more concise method for generating iterators, without the need for tedious and complexIteratorInterface.
A simple example: use generators to implement the same iteration function as the range function
xrange(, , = 1 ( = ; <= ; += 'Single digit odd numbers: ' (xrange(1, 9, 2) " " "\n";
The above routine will output:
Single digit odd numbers: 1 3 5 7 9
2. add the finally keyword
The try-catch statement supports finally addition later. Whether or not an exception is thrown, the finally code is always executed.
3. new hash API
A new hash function API is added, which can generate secure hash values and be used for password verification management like crypt. For details, see password_hash ().
4. foreach supports list ()
Now, foreach can use the list () structure to break down nested arrays and extract the values. For example:
=1, 2],3, 4], ( (, "A: ; B: \n"
The above routine will output:
A: 1; B: 2
A: 3; B: 4
For more information, see The foreach manual.
5. empty () supports expressions.
Now any expression can be passed into empty. For example:
( "This will be printed.\n" (( "This will not be printed.\n"
The above routine will output:
This will be printed.
6. array and string literal dereferencing
You can use subscript to access an element or char in array or string. (Ps: dereferencing is accurate without knowing how to translate... read the expression of Xuan Mai Blade: it supports obtaining with subscript, haha, it actually means this .)
'Array dereferencing: ' [1, 2, 3][0 "\n" 'String dereferencing: ' 'PHP'[0 "\n";
The above routine will output:
Array dereferencing: 1
String dereferencing: P
7. get the class name through: class
AvailableClassName: classObtain the complete class name of the class. For example:
ClassName:: "\n";
The above routine will output:
Name \ Space \ ClassName
8. added extended OPcache.
Zend Optimiser + opcode cache is added to the php extension and becomes the OPcache extension. OPcache can improve php's execution performance. it can store compiled opcode in the shared memory to save the time for loading \ parsing php scripts for each request. For more information about installation and use, see the installation instructions.
9. foreach supports non-standard keys.
Foreach now supports any type of key. The native php array can only use a scalar as the key, but now it can return any type of data by implementing Iterator: key (), and foreach can receive.
10. support for Apache 2.4 on win platform
The SAPI for apache2.4 on windows has been implemented and supported.
11. GD improvement
The GD extension has made many improvements, including:
New features of PHP 5.5 released today. However, there is no translation, I am here to add a little, sort into a complete article :) original: http://www.php.net/manual/zh/migration55 ....