php5.3
New features
1. Support Namespaces (namespace)
5.3 ago
Copy CodeThe code is as follows:
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:
Namespace Zend/db/table
Class Select {
}
2. Support for lazy static bindings
5.3 Before (__class__ get class name) self::who ()
Copy CodeThe code is as follows:
Class A {
public static function who () {
Echo __class__;
}
public static function test () {
Self::who ();
}
}
Class B extends A {
public static function who () {
Echo __class__;
}
}
B::test ();
?>
Output A
5.3 (__class__ obtains the class name) static::who ();
Copy CodeThe code is as follows:
Class A {
public static function who () {
Echo __class__;
}
public static function test () {
Static::who (); This implements a static binding of delay
}
}
Class B extends A {
public static function who () {
Echo __class__;
}
}
B::test ();
?>
Output B
3. Support Goto Statement
In most computer programming languages, the unconditional turn statement Goto is supported, and when the program executes to a goto statement, it moves to the program location indicated by the label in the Goto statement to continue execution.
4. Support Closures
Copy CodeThe code is as follows:
$msg = "Hello";
$callback = function () use ($msg) {
Print_r ($msg);
}
$msg = "Hello world!";
Callback ($callback);
output
Hello
Hello world!
5. New Magic Method __callstatic ()
PHP originally had a magic method __call (), and the Magic method would be called automatically when the code called a non-existent method of the object.
The new __callstatic () method is used only for static class methods. The __callstatic () Magic method is called automatically when attempting to invoke a static method that does not exist in the class.
6. Add a way to define constants (sometimes code errors, such as undefined HE, you want to see if Const is supported)
Copy the Code code as follows:
Const CONSTANT = ' Hello world ';
http://www.bkjia.com/PHPjc/327975.html www.bkjia.com true http://www.bkjia.com/PHPjc/327975.html techarticle php5.3 new features 1. Support for namespaces (namespace) 5.3 The previously copied code code is as follows:? PHP class Zend_db_table_select {//indicates that the current class file is under Zend/db/table} 5....< /c5>