A simple example of PHP static Deferred binding. This new feature has not been used in simple PHP static latency binding examples, but it is not new. try it, now the inheritance of static classes facilitates the simple example of classA {protectedstatic $ def12345 PHP static latency binding
I have never used this new feature, but it is not new. try it. it is very convenient to inherit static classes.
Class {
Protected static $ def = '20140901 ';
Public static function test (){
Echo get_class (new static );
}
Public static function test2 (){
Echo static: $ def;
}
}
Class B extends {
Protected static $ def = '20140901 ';
}
Class C extends {
Protected static $ def = 'abcdef ';
}
Echo B: test ();
Echo'
';
Echo C: test ();
Echo'
';
Echo B: test2 ();
Echo'
';
Echo C: test2 ();
Echo'
';
Echo A: test ();
Echo'
';
Echo A: test2 ();
Echo'
';
// Output result
B
C
456789
Abcdef
A
123456
I have never used this new feature before, but it is not new. try it. now the inheritance of static classes is very convenient for class A {protected static $ def = '100...