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.