3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
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.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.51 ms | 401 KiB | 8 Q