Summary of new features of PHP53

Source: Internet
Author: User
This paper summarizes and analyzes the new characteristics of PHP5.3. Share to everyone for your reference, as follows:

1. namespace resolves the problem of class, function and constant name conflicts

2. When a static binding inherits, the parent class can call the subclass directly to override the parent class's method

Class A {public  static function who () {    echo __class__;  }  public static function test () {    static::who ();//Late static binding starts here  }}class B extends A {public  static function () {    echo __class__;  }} B::test ();

3, anonymous function, also called the closure function (closures), allows temporary creation of a function without a specified name. Most often used as a callback function

The anonymous function does the callback function Uasort ($arr, function ($a, $b) {})

The closure function can also be used as the value of a variable

$FN = function ($a) {  echo $a;}; $FN (1);

PHP automatically converts an expression into an object instance of the built-in class closure

$FN = function ($a) {  echo $a;}; EE ($FN);/** * Closure Object (  [parameter] = Array    (      [$a] =     )) */

Anonymous functions are now implemented through the closure class. is not yet stable and does not apply to formal development

3,?: operator

$a = 0; $b = 2;ee ($a?: $b); # 2 similar to JS | |

4, new constant __dir_

5, new garbage collection mechanism, solve the problem of circular reference

Gc_enable (); Activates the Loop reference collector, which turns on Var_dump (Gc_collect_cycles ()) by default; Forced reclamation of an invalid variable gc_disable (); Disable GC

Read more about PHP related content readers can view the topic: "PHP Basic Grammar Introductory Tutorial", "PHP error and Exception handling method summary" and "PHP common functions and Skills summary"

I hope this article is helpful to you in PHP programming.

The above describes the PHP53 new features summary, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.