3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function bool2str($bool) { if ($bool === false) { return 'FALSE'; } else { return 'TRUE'; } } function compareObjects(&$o1, &$o2) { echo 'o1 == o2 : ' . bool2str($o1->equals($o2)) . "\n"; echo 'o1 != o2 : ' . bool2str($o1 instanceof $o2) . "\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 7.0.0 - 7.1.0
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Flag has a deprecated constructor in /in/P4hSI on line 17 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OtherFlag has a deprecated constructor in /in/P4hSI on line 26 Два экземпляра одного и того же класса Fatal error: Uncaught Error: Call to undefined method Flag::equals() in /in/P4hSI:13 Stack trace: #0 /in/P4hSI(41): compareObjects(Object(Flag), Object(Flag)) #1 {main} thrown in /in/P4hSI on line 13
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Два экземпляра одного и того же класса Fatal error: Call to undefined method Flag::equals() in /in/P4hSI on line 13
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/P4hSI on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/P4hSI on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/P4hSI on line 14
Process exited with code 255.