I. parameter and return value type declaration
It can be stated that: float,int,bool,string,interfaces,array,callable
General mode:
function sum(int ...$ints) { return array_sum($ints); } print(sum(2, ‘3‘, 4.1)); //9
Strict mode: Declare (strict_types= 1); function sum (int ... $ints) {return array_sum ($ints); } print (SUM (2, ' 3 ', 4.1)); //fatal error:uncaught typeerror:argument 2 passed to sum () must is of the type Integer, String giv En, ...
return value:
Declare (strict_types = Span class= "Hljs-number" >1); function returnIntValue (int $value): int {return $value + 1.0; } print (Returnintvalue (5));
two.
Empty merge operator
isset ($_get[ ' AA '])? $_get[< Span class= "hljs-string" > ' AA ']: ' not passed ' equivalent to
$_get[ ' AA ']??:
Not passed ';
three.
spaceship operator
print (1 <=> 1)//0 print ( Span class= "Hljs-number" >1 <=> 2);//-1 print (2 <=> 1 );//1
four. To define a solid array
define (' animals
Five.
Filter Unserialize
PHP 7 introduces a filtered unserialize () function to provide better security when deserializing objects on untrusted data. It prevents possible code injection and allows developers to whitelist classes that can be deserialized.
Six. Use batch declaration
under the same namespace, now you can batch declare
use some/namespace/{classa, Classb, classc as c};
seven. Support for negative string offsets
var_dump("abcdef"[-2]);var_dump(strpos("aabbcc", "b", -3));
八.
foreach no longer changes the internal array pointer
$array = [0, 1, 2];foreach ($array as &$val) { var_dump(current($array));}
PHP5 output:
Int (1)
Int (2)
BOOL (FALSE)
PHP7 Output :
Int (0)
Int (0)
Int (0)
PHP7 New Content Summary (update at any time)