fork download
  1. <?php
  2.  
  3. /// parent class
  4. interface iA {
  5. public function execute($str = '');
  6. }
  7.  
  8. class A implements iA {
  9.  
  10. public function __construct() { }
  11.  
  12. public function execute($str = '')
  13. {
  14. return 'Execution ' . $str;
  15. }
  16. }
  17.  
  18. /// child class
  19. interface iB {
  20. public function execute();
  21. }
  22.  
  23. class B extends A implements iB {
  24.  
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29.  
  30. public function execute()
  31. {
  32. return parent::execute();
  33. }
  34.  
  35. }
  36.  
  37. var_dump((new B)->execute());
Runtime error #stdin #stdout #stderr 0.03s 52480KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Declaration of B::execute() must be compatible with iA::execute($str = '') in /home/9cVKxz/prog.php on line 23