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('b'); $first_dogecoin = new DogeCoin('b'); $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)); var_dump($first_doge->equalsWithSubType($first_dogecoin)); var_dump($first_doge->equalsWithRandomType($first_somethingelsecompletely));
Output for git.master, git.master_jit, rfc.property-hooks
bool(false) bool(false) Fatal error: Uncaught Error: Cannot access private property SomethingElseCompletely::$name in /in/DscPG:51 Stack trace: #0 /in/DscPG(90): Doge->equalsWithRandomType(Object(SomethingElseCompletely)) #1 {main} thrown in /in/DscPG 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:
43.23 ms | 401 KiB | 8 Q