3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A{ function do_stuff(&$b) { var_dump('Before in function:', $b); $defined = 0; #trigger_error("If I fixed the undefined variable but enabled this line instead, it will also turn b from an object into a string! So user-triggered notices bork it as well."); $x = $undefined || $defined ? 14 : 0; var_dump('After in function:', $b); } } class B{} $a = new A(); $b = new B(); $a->do_stuff($b); var_dump('After function:', $b); ?>
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
string(19) "Before in function:" object(B)#2 (0) { } Notice: Undefined variable: undefined in /in/fZij6 on line 7 string(18) "After in function:" object(B)#2 (0) { } string(15) "After function:" object(B)#2 (0) { }
Output for 5.0.0 - 5.0.3
string(19) "Before in function:" object(B)#2 (0) { } Notice: Undefined variable: undefined in /in/fZij6 on line 7 string(18) "After in function:" object(B)#2 (0) { } string(15) "After function:" object(B)#2 (0) { }
Output for 4.3.0 - 4.4.9
string(19) "Before in function:" object(b)(0) { } Notice: Undefined variable: undefined in /in/fZij6 on line 7 string(18) "After in function:" object(b)(0) { } string(15) "After function:" object(b)(0) { }