Php5.3 considerations. New features in php5.3 1. support for namespace before 5.3 copy the code as follows :? PhpclassZend_Db_Table_Select {indicates that the current class file is located under ZendDbTable} 5. php5.3
New features
1. namespace is supported)
Before 5.3
The code is as follows:
Class Zend_Db_Table_Select {
// Indicates that the current class file is located under Zend/Db/Table
}
5.3
The code is as follows:
Namespace Zend/Db/Table
Class Select {
}
2. support for delayed static binding
Before 5.3 (_ CLASS _ obtains the CLASS name) self: who ()
The code is as follows:
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 ();
The code is as follows:
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
The code is as follows:
$ 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)
The code is as follows:
Const CONSTANT = 'Hello World ';
Http://www.bkjia.com/PHPjc/327975.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327975.htmlTechArticlephp5.3 New Features 1. support namespace 5.3 previous code :? Php class Zend_Db_Table_Select {// indicates that the current class file is located under Zend/Db/Table} 5 ....