3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function modify_in_place($prices) { $prices[0] = 100; } function modify_location($prices) { $prices = [40, 50, 60]; } $prices = [1, 2, 3]; modify_in_place($prices); if ($prices[0] == 100) { echo "Pass-by-reference!"; } else { echo "Pass-by-value!"; } $prices = [1, 2, 3]; modify_location($prices); assert($prices[0] == 40); //failed! pass-by-value
based on VVKSm
Output for 7.0.0 - 7.2.0
Pass-by-value! Warning: assert(): assert($prices[0] == 40) failed in /in/fW2T3 on line 23
Output for 5.4.2 - 5.6.28
Pass-by-value! Warning: assert(): Assertion failed in /in/fW2T3 on line 23
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/fW2T3 on line 8
Process exited with code 255.