3v4l.org

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