fork download
  1. <?php
  2.  
  3. class A {
  4. public function example() {
  5. return new static;
  6. }
  7. }
  8.  
  9. class B extends A {
  10.  
  11. }
  12.  
  13. $b = new B();
  14. $obj = $b->example();
  15.  
  16. echo get_class($obj), PHP_EOL;
  17.  
  18. // Saída:
  19. // B
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
B