3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bool2str($bool) { if ($bool === false) { return 'FALSE'; } else { return 'TRUE'; } } function compareObjects(&$o1, &$o2) { echo 'o1 == o2 : ' . bool2str($obj1->equals($obj2)) . "\n"; echo 'o1 != o2 : ' . bool2str($obj1 instanceof $obj2) . "\n"; } class Flag { public $flag; function Flag($flag = true) { $this->flag = $flag; } } class OtherFlag { public $flag; function OtherFlag($flag = true) { $this->flag = $flag; } } $o = new Flag(); $p = new Flag(); $q = $o; $r = new OtherFlag(); echo "Два экземпляра одного и того же класса\n"; compareObjects($o, $p); echo "\nДве ссылки на один и тот же экземпляр\n"; compareObjects($o, $q); echo "\nЭкземпляры двух разных классов\n"; compareObjects($o, $r);
Output for git.master, git.master_jit, rfc.property-hooks
Два экземпляра одного и того же класса Warning: Undefined variable $obj1 in /in/PA16c on line 13 Fatal error: Uncaught Error: Call to a member function equals() on null in /in/PA16c:13 Stack trace: #0 /in/PA16c(41): compareObjects(Object(Flag), Object(Flag)) #1 {main} thrown in /in/PA16c on line 13
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:
39.07 ms | 401 KiB | 8 Q