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 { 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; echo $class->prefixName("Pacman"), "\n"; echo $class->prefixName("Pacwoman"), "\n"; ?>
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function ConcreteClass::__construct(), 0 passed in /in/F6l60 on line 31 and exactly 1 expected in /in/F6l60:14 Stack trace: #0 /in/F6l60(31): ConcreteClass->__construct() #1 {main} thrown in /in/F6l60 on line 14
Process exited with code 255.
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.0.14
Warning: Missing argument 1 for ConcreteClass::__construct(), called in /in/F6l60 on line 31 and defined in /in/F6l60 on line 14 Notice: Undefined variable: a in /in/F6l60 on line 15 Mr0 Pacman Mrs0 Pacwoman
Output for hhvm-3.10.0 - 3.12.0
Warning: __construct() expects exactly 1 parameter, 0 given in /in/F6l60 on line 15 Notice: Undefined variable: a in /in/F6l60 on line 15 Mr0 Pacman Mrs0 Pacwoman
Output for 5.2.3 - 5.4.45
Warning: Missing argument 1 for ConcreteClass::__construct(), called in /in/F6l60 on line 31 and defined in /in/F6l60 on line 14 Mr0 Pacman Mrs0 Pacwoman
Output for 5.1.0 - 5.2.2
<br /> <b>Warning</b>: Missing argument 1 for ConcreteClass::__construct(), called in /in/F6l60 on line 31 and defined in <b>/in/F6l60</b> on line <b>14</b><br /> Mr0 Pacman Mrs0 Pacwoman
Output for 5.0.0 - 5.0.5
<br /> <b>Warning</b>: Missing argument 1 for ConcreteClass::__construct() in <b>/in/F6l60</b> on line <b>14</b><br /> Mr0 Pacman Mrs0 Pacwoman
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_CLASS in <b>/in/F6l60</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_CLASS in <b>/in/F6l60</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/F6l60</b> on line <b>2</b><br />
Process exited with code 255.