fork download
  1. <?php
  2.  
  3. class A{
  4. public static function test(){
  5. return new self();
  6. }
  7.  
  8. public static function another_test(){
  9. return new static();
  10. }
  11.  
  12. public static function alert(){
  13. echo "A";
  14. }
  15. }
  16.  
  17. class B extends A{
  18. public static function alert(){
  19. echo "B";
  20. }
  21. }
  22.  
  23. $b = new B();
  24. $c = B::test();
  25. $c->alert();
  26.  
  27. $d = B::another_test();
  28. $d->alert();
Success #stdin #stdout 0.02s 24596KB
stdin
Standard input is empty
stdout
AB