php5.3
New features
1. Support namespace (namespace)
Before 5.3
Copy the code The code is as follows:
class Zend_Db_Table_Select {
//Indicates that the current class file is located under Zend/Db/Table
}
5.3
Copy code The code is as follows:
namespace Zend/Db/Table
class Select {
}
2. Support delayed static binding
Before 5.3 (__CLASS__ gets the class name) self::who()
Copy code The 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__ gets the class name) static::who();
Copy code The code is as follows:
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
static::who(); // Delayed static binding is implemented here
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
B::test();
?>
Output B
3. Support goto statement
Most computer programming languages support the unconditional goto statement goto. When the program is executed When a goto statement is issued, execution will continue at the program location indicated by the label in the goto statement.
4. Support closures
Copy code The 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()
There is originally a magic method __call() in PHP. When the code calls a non-existent object The magic method will be automatically called when the method is used.
The new __callStatic() method is only used for static class methods. When trying to call a static method that does not exist in the class, the __callStatic() magic method will be automatically called.
6. Add a new way to define constants (sometimes code errors, such as undefined HE, you have to see if const is supported)
Copy code 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 (namespace) The code copied before 5.3 is as follows: ?php class Zend_Db_Table_Select { //Indicates that this class file is currently located under Zend/Db/Table} 5....