fork download
  1. <?php
  2.  
  3. class A {
  4. const X = 'A';
  5. public function x() {
  6. echo static::X;
  7. }
  8. }
  9.  
  10. class B {
  11. public static $X = 'B';
  12. public function x() {
  13. echo self::$X;
  14. }
  15. public function x2() {
  16. echo B::$X;
  17. }
  18. }
  19.  
  20. class C extends A {
  21. const X = 'C';
  22. }
  23.  
  24. $c = new C();
  25. $c->x();
  26. echo C::X;
  27. echo c::X;
  28. $b = new B();
  29. $b->x();
  30. $b->x2();
  31. echo b::$X;
  32. echo B::$X;
  33.  
  34. //https://pt.stackoverflow.com/q/242625/101
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
CCCBBBB