php5.3 Note Description _php tutorial

Source: Internet
Author: User
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>

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.