PHP Static Delay Binding Simple example
Not how to use this new feature, in fact, it is not new, try it, now static class inheritance is very convenient
Class A {
protected static $def = ' 123456 ';
public static function test () {
Echo get_class (new static);
}
public static function Test2 () {
echo Static:: $def;
}
}
Class B extends A {
protected static $def = ' 456789 ';
}
Class C extends A {
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 results
B
C
456789
ABCdef
A
123456
http://www.bkjia.com/PHPjc/820417.html www.bkjia.com true http://www.bkjia.com/PHPjc/820417.html techarticle PHP Static Delay binding Simple example did not use this new feature, in fact, is not new, try it, now static class inheritance is very convenient class A {protected static $def = ' 12345 ...