3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Doge { private $name; protected $whatever; public $yolo; public function __construct($name, $whatever = null) { $this->name = $name; $this->whatever = $whatever; } public function getName() { return $this->name; } public function getWhatever() { return $this->whatever; } public function equalsWithSameType(self $other) { if ($other->name === $this->name && $other->whatever === $this->whatever && $other->yolo === $this->yolo) { return true; } return false; } public function equalsWithSubType(DogeCoin $sub) { if ($sub->name === $this->name && $sub->whatever === $this->whatever && $sub->yolo === $this->yolo) { return true; } return false; } public function equalsWithRandomType(SomethingElseCompletely $whatever_man) { if ($whatever_man->name === $this->name && $whatever_man->whatever === $this->whatever && $whatever_man->yolo === $this->yolo) { return true; } return false; } } class DogeCoin extends Doge { private $name; } class SomethingElseCompletely { private $name; } $first_doge = new Doge('a'); $second_doge = new Doge('a'); $first_dogecoin = new DogeCoin('a'); $second_dogecoin = new DogeCoin('a'); $first_somethingelsecompletely = new SomethingElseCompletely('a'); $second_somethingelsecompletely = new SomethingElseCompletely('a'); var_dump( $first_doge, $second_doge, $first_dogecoin, $second_dogecoin, $first_somethingelsecompletely, $second_somethingelsecompletely ); var_dump( $first_doge->equalsWithSameType($second_doge), $first_doge->equalsWithSubType($first_dogecoin), $first_doge->equalsWithRandomType($first_somethingelsecompletely) );
Output for git.master, git.master_jit, rfc.property-hooks
object(Doge)#1 (3) { ["name":"Doge":private]=> string(1) "a" ["whatever":protected]=> NULL ["yolo"]=> NULL } object(Doge)#2 (3) { ["name":"Doge":private]=> string(1) "a" ["whatever":protected]=> NULL ["yolo"]=> NULL } object(DogeCoin)#3 (4) { ["name":"Doge":private]=> string(1) "a" ["whatever":protected]=> NULL ["yolo"]=> NULL ["name":"DogeCoin":private]=> NULL } object(DogeCoin)#4 (4) { ["name":"Doge":private]=> string(1) "a" ["whatever":protected]=> NULL ["yolo"]=> NULL ["name":"DogeCoin":private]=> NULL } object(SomethingElseCompletely)#5 (1) { ["name":"SomethingElseCompletely":private]=> NULL } object(SomethingElseCompletely)#6 (1) { ["name":"SomethingElseCompletely":private]=> NULL } Fatal error: Uncaught Error: Cannot access private property SomethingElseCompletely::$name in /in/uJU9o:51 Stack trace: #0 /in/uJU9o(91): Doge->equalsWithRandomType(Object(SomethingElseCompletely)) #1 {main} thrown in /in/uJU9o on line 51
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:
36.64 ms | 402 KiB | 8 Q