php5.3 Note Notes

Source: Internet
Author: User
Tags constant constant definition goto static class zend

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 ';

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.