3v4l.org

run code in 300+ PHP versions simultaneously
<?php class T{ public $value; public $ref; function equals($other, $origin = null){ if($this->value !== $other->value) return false; if($this->ref === ($origin ?? $this)) return true; return $this->ref->equals($other->ref, $origin ?? $this); } } $a1 = new T; $a1->value = 10; $a2 = new T; $a2->value = 20; $a3 = new T; $a3->value = 30; $a1->ref = $a2; $a2->ref = $a3; $a3->ref = $a1; $b1 = new T; $b1->value = 10; $b2 = new T; $b2->value = 20; $b3 = new T; $b3->value = 30; $b1->ref = $b2; $b2->ref = $b3; $b3->ref = $b1; var_dump($a1->equals($b1)); $b3->value +=10; var_dump($a1->equals($b1));
Output for git.master, git.master_jit, rfc.property-hooks
bool(true) bool(false)

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:
70.22 ms | 401 KiB | 8 Q