Php5.3
New Features
1. namespace is supported)
Before 5.3
Copy codeThe Code is as follows: <? Php
Class Zend_Db_Table_Select {
// Indicates that the current class file is located under Zend/Db/Table
}
5.3
Copy codeThe Code is as follows: <? Php
Namespace Zend/Db/Table
Class Select {
}
2. Support for delayed static binding
Before 5.3 (_ CLASS _ obtains the CLASS name) self: who ()
Copy codeThe Code is as follows: <? Php
Class {
Public static function who (){
Echo _ CLASS __;
}
Public static function test (){
Self: who ();
}
}
Class B extends {
Public static function who (){
Echo _ CLASS __;
}
}
B: test ();
?>
Output
5.3 (_ CLASS _ Get CLASS name) static: who ();
Copy codeThe Code is as follows: <? Php
Class {
Public static function who (){
Echo _ CLASS __;
}
Public static function test (){
Static: who (); // latency static binding is implemented here
}
}
Class B extends {
Public static function who (){
Echo _ CLASS __;
}
}
B: test ();
?>
Output B
3. Support for goto statements
Most computer programming languages support unconditional redirection to the goto statement. When the program is executed to the goto statement, the program is switched to the position indicated by the label in the goto statement to continue execution.
4. Support for closures
Copy codeThe Code is as follows: <? Php
$ Msg = "hello ";
$ Callback = function () use ($ msg ){
Print_r ($ msg );
}
$ Msg = "hello world! ";
Callback ($ callback );
Output
Hello
Hello world!
5. added the magic method _ callStatic ()
PHP originally had a magic method _ call (). When the code calls a non-existent method of the object, the magic method is automatically called.
The new _ callStatic () method is only used for static class methods. When you try to call a static method that does not exist in the class, the __callstatic () magic method is automatically called.
6. added a constant definition method (sometimes code errors, such as undefined HE, you need to check whether const is supported)
Copy codeThe Code is as follows: <? Php
Const CONSTANT = 'Hello world ';