3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class AbstractClass { public function __construct() { echo 'aaa'; } // Our abstract method only needs to define the required arguments abstract protected function prefixName($name); } class ConcreteClass extends AbstractClass { // Our child class may define optional arguments not in the parent's signature public function prefixName($name, $separator ) { if ($name == "Pacman") { $prefix = "Mr"; } elseif ($name == "Pacwoman") { $prefix = "Mrs"; } else { $prefix = ""; } return "{$prefix}{$separator} {$name}"; } } $class = new ConcreteClass; echo $class->prefixName("Pacman"), "\n"; echo $class->prefixName("Pacwoman"), "\n"; ?>
Output for 5.4.0 - 5.4.22
Fatal error: Declaration of ConcreteClass::prefixName() must be compatible with AbstractClass::prefixName($name) in /in/YEo4Q on line 26
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Fatal error: Declaration of ConcreteClass::prefixName() must be compatible with that of AbstractClass::prefixName() in /in/YEo4Q on line 26
Process exited with code 255.