3v4l.org

run code in 300+ PHP versions simultaneously
<?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); echo (bool)($prices[0] == 100); //failed! pass-by-value $prices = [1, 2, 3]; modify_location($prices); assert($prices[0] == 40); //failed! pass-by-value
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught AssertionError: assert($prices[0] == 40) in /in/VVKSm:17 Stack trace: #0 /in/VVKSm(17): assert(false, 'assert($prices[...') #1 {main} thrown in /in/VVKSm on line 17
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: assert(): assert($prices[0] == 40) failed in /in/VVKSm on line 17
Output for 5.4.8 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Warning: assert(): Assertion failed in /in/VVKSm on line 17

preferences:
182.86 ms | 402 KiB | 221 Q