fork download
  1. <?php
  2.  
  3. interface A {
  4. public function hello();
  5. }
  6.  
  7. abstract class B implements A {
  8. public function __construct() {
  9. if (method_exists($this, "hello"))
  10. {
  11. $this->hello();
  12. }
  13. }
  14. }
  15.  
  16.  
  17. class C extends B {
  18. public function __contruct() {
  19. parent::__construct();
  20. }
  21.  
  22. public function hello() {
  23. echo "Hello world!";
  24. }
  25. }
  26.  
  27. $B = new C();
Success #stdin #stdout 0.02s 24488KB
stdin
Standard input is empty
stdout
Hello world!