3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Doge { private $name = "Testing"; public function __construct($name) { } public function getName() { return $this->name; } public function equalsWithSameType(self $other) { return ($other->name === $this->name); } public function equalsWithSubType(DogeCoin $sub) { return ($sub->name === $this->name); } public function foo(Doge $d){ return ($d->name === $this->name); } } class DogeCoin extends Doge { private $name = "Testing"; } $doge = new Doge('a'); $doge_coin = new DogeCoin('a'); var_dump($doge->foo($doge_coin));

preferences:
40.46 ms | 402 KiB | 5 Q