3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Animal { protected string $name; public function __construct(string $name) { $this->name = $name; } abstract public function speak(); } class Cat extends Animal { public function speak() { echo $this->name . " meows"; } } // However, covariant return types cannot return a more broad type interface AnimalShelter { public function adopt(string $name): Cat; } class CatShelter implements AnimalShelter { public function adopt(string $name): Animal { return new Animal($name); } } $kitty = (new CatShelter)->adopt("Ricky"); $kitty->speak();
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Declaration of CatShelter::adopt(string $name): Animal must be compatible with AnimalShelter::adopt(string $name): Cat in /in/Lkn8j on line 32
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:
94.36 ms | 1513 KiB | 4 Q