Laravel framework principles (a) - Laravel commonly used PHP syntax

A. Late static binding

  Starting from PHP 5.3.0, PHP adds feature called late static binding, used to refer to a static class called within the scope of inheritance. Used to refer to a static class called within the scope of inheritance, that is, in the process of succession in the class, the class is no longer used in the current class, but the class calls.

  Here's an example, using the specific principles and refer to the PHP manual in which detailed the late static binding.

Class A {
     public  static  function Create () {
         $ Self = new new Self (); // instance class location 
        $ static = new new  static (); // call the class instances 
        return  Array ( $ Self , $ static ); 
    } 
} 
class B the extends A { 
} 

$ ARR = B :: Create ();
 var_dump ( $ ARR [0 ]);
 var_dump ( $ ARR [. 1]);

 Output:

object(A)#3 (0) {}
object(B)#4 (0) {}

 

The same output result above, in the instance of the object, static can be determined according to the objects instantiated class operation time of the call, the self is determined according to instantiate an object class of the location

II. Reflection

Three .trait

IV. Closure function

Guess you like

Origin www.cnblogs.com/slothccc/p/11671453.html