The performance breakthrough in PHP 7 has become one of the hottest topics in recent times, and currently the official PHP 7.0.0 Beta 2 has been released
New features
Performance Improvement: PHP 7 is twice times faster than PHP 5.6
Full and consistent 64-bit support
Removed some old unsupported sapi (server-side application programming ports) and extensions
Added the null engagement operator (??) "Wiki"
$username = $_get[' user ']?? ' Nobody ';
Equivalent to: $username = isset ($_get[' user '))? $_get[' user ']: ' nobody ';
New added 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 return type of function declares "wiki"
function foo (): array {
return [];
}
New scalar type declaration "wiki" added
The main function of scalar declarations is to automatically implement mandatory type conversions of parameters
Variable type declarations (int, float, string, bool)
function add (int $a, int $b): int {
return $a + $b;
}
New Add anonymous class "wiki"
Class Foo {}
$child = new class extends Foo {};
Var_dump ($child instanceof Foo); True
Fatal errors can be caught, and older versions can only be processed after 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, $a);
}
The test results are as follows
It can be seen that PHP 7 is more than a few times faster than PHP 5.4.
Benchmark results in the community:
To WordPress Open Source Blog Home page for testing the test results: