What are the new features of PHP 7? The new features of PHP7 mainly improve the performance. We can achieve the acceleration performance without using the php acceleration plug-in as long as php 7 is used. Is that true? Let's take a look at the new features of PHP 7. What are the new features of PHP 7? The new features of PHP 7 mainly improve the performance. We can achieve the acceleration performance without using the php acceleration plug-in as long as PHP 7 is used. Is that true? Let's take a look at the new features of PHP 7.
Script ec (2); script
PHP 7's performance breakthrough has become one of the hottest topics recently. The official PHP 7.0.0 Beta 2 has been released.
New Features
Performance Improvement: PHP 7 is twice faster than PHP 5.6
Fully consistent 64-bit support
Removed some old unsupported SAPI (server-side application programming port) and extensions
Added the null join operator (??) [Wiki]
$ Username = $ _ GET ['user']? 'Nobody ';
// Equivalent to: $ username = isset ($ _ GET ['user'])? $ _ GET ['user']: 'nobody ';
Added the combined comparison operator (<=>) [wiki]
$ A = 1;
$ B = 2;
Switch ($ a <=> $ B)
{
Case 1:
Echo "a> B ";
Break;
Case 0:
Echo "a = B ";
Break;
Case-1:
Echo "a <B ";
Break;
}
Newly Added function return type declaration [wiki]
Function foo (): array {
Return [];
}
A scalar type declaration [wiki] is added]
// The main function of scalar declaration is to automatically implement forced type conversion of parameters.
// Variable type declaration (int, float, string, bool)
Function add (int $ a, int $ B): int {
Return $ a + $ B;
}
New Anonymous class [wiki]
Class Foo {}
$ Child = new class extends Foo {};
Var_dump ($ child instanceof Foo); // true
Fatal errors can be captured. Earlier versions can only be post-processed through register_shutdown_function. (Wiki)
Benchmark
Test code:
$ Count = $ argv [1];
$ A = array ();
For ($ I = 0; $ I <$ count; $ I ++ ){
$ A [$ I] = $ I;
}
Foreach ($ a as $ I ){
Array_key_exists ($ I, $ );
}
The test results are as follows:
It can be seen that PHP 7 is more than several times faster than PHP 5.4.
Benchmark Results in the community:
Test results of the test scenario on the WordPress open source blog homepage: