Nothing today, and occasionally see the version selection in Phpstorm a short description of the differences between the editions, so summarize.
PHP5.3 compared to the previous version, the biggest difference is the namespace and anonymous functions, which in peacetime development and the big frame are used more, it is no longer detailed.
The main update for PHP5.4 is the array shorthand syntax format and traits.
On the array shorthand, it is very simple to say, just add a new declaration method for the group, as follows:
// PHP5.4之前$array = array( "foo" => "bar", "bar" => "foo",);// 自 PHP 5.4 起$array = [ "foo" => "bar", "bar" => "foo",];
And the traits about PHP5.4 is relatively rare, code description:
class Base { public function sayHello() { echo 'Hello '; }}trait SayWorld { public function sayHello() { parent::sayHello(); echo 'World!'; }}class MyHelloWorld extends Base { use SayWorld;}$o = new MyHelloWorld();$o->sayHello();
Note: The result is ' Hello world! ', the method inherited from the base class is overwritten by the method with the same name in the trait, the method in the current class overrides the member of the same name in the trait, and if the attribute is defined in trait, the same name property cannot be defined in the current class; Abstract methods and static members can also be defined in trait. You can use multiple trait, separated by commas, as follows:
use SayHello1,SayHello2;
If there are members of the same name in SayHello1 and SayHello2, a fatal error is generated and the workaround is as follows:
use SayHello1,SayHello2 { SayHello1::sayHello insteadof SayHello2; // 意思是用SayHello1中的sayHello方法代替SayHello2中的同名方法,注:此处的sayHello不一定是静态方法 // ... // 或 SayHello1::sayHello as sayHello1; // 为其另取一个名字,也可解决}
The change in PHP5.5 is mainly the addition of the Finally keyword and the generator generator in exception handling.
About finally, the code description:
try { throw new ErrorException('Some Error Message');} catch (ErrorException $e) { echo $e->getMessage()."111 \n";} catch(Exception $e) { echo $e->getMessage()."222 \n";} finally { echo 'finally';}
No matter the production is not abnormal, will output finally.
About generator generator, I looked at the manual, unknown. Yes, plus ...
Come here today first ...
The above describes the PHP53, 54, 55, 56 important update Brief (above), including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.