php5.3
New features
1. Support Namespaces (namespace)
5.3 ago
Copy Code code as follows:
<?php
class Zend_db_table_select {
//Indicates that the current class file is located under Zend/db/table
}
5.3
Copy Code code as follows:
<?php
namespace Zend/db/table
class Select {
}
2. Support for deferred static binding
before 5.3 (__class__ get class name) self::who ()
Copy Code code as follows:
<?php
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__ obtained class name) static::who ();
Copy Code code as follows:
<?php
class A {
public static function, who () {
Echo __class__;
}
public static function test () {
static::who (); This implements the deferred static binding
}
}
class B extends A {
public static function, who () {
Echo __class__;
}
}
b::test ();
?>
Output B
3. Support Goto Statement
in most computer programming languages, an unconditional turn statement Goto is supported, and when the program executes to a goto statement, it moves on to the program location indicated by the label in the Goto statement.
4. Support Closure
Copy Code code as follows:
<?php
$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 a magic method __call () in PHP that is invoked automatically when the code calls a nonexistent method of the object.
The new __callstatic () method is used only for static class methods. When trying to invoke a static method that does not exist in a class, the __callstatic () Magic method is invoked automatically.
6. Add a new constant definition method (sometimes the code goes wrong, like undefined he, you want to see if it supports const)
Copy Code code as follows:
<?php
Const CONSTANT = ' Hello world ';