3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(&$obj) { return $obj; } $o = new StdClass; // No errors foo($o); call_user_func('foo', $o); call_user_func('foo', [$o]); $a[] = $o; $a[] = $o; $a[] = $o; // Warning: Parameter 1 to foo() expected to be a reference, value given in call_user_func('foo', array_slice($a, 0, 1));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Warning: foo(): Argument #1 ($obj) must be passed by reference, value given in /in/oBnkT on line 10 Warning: foo(): Argument #1 ($obj) must be passed by reference, value given in /in/oBnkT on line 11 Warning: foo(): Argument #1 ($obj) must be passed by reference, value given in /in/oBnkT on line 18
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 10 Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 11 Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 18
Output for 7.0.0 - 7.0.8, 7.0.10 - 7.0.33
Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 18
Output for 7.0.9
Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 10 Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 18
Output for 5.6.0 - 5.6.40
Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 10

preferences:
148.96 ms | 411 KiB | 5 Q