3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL); ini_set('display_errors', true); function by_ref(&$value) { echo "Call by ref value:\n"; var_dump($value); } function by_value($value) { echo "Call by value value:\n"; var_dump($value); } $thing = array(1,2); echo "Before call by ref:\n"; var_dump($thing); by_ref($thing[5][6]); echo "After call by ref:\n"; var_dump($thing); echo "Before call by value\n"; by_value($thing[7][8]); echo "After call by value:\n"; var_dump($thing); echo "Before call by ref again:\n"; by_ref($thing[7][8]); echo "After call by ref again:\n"; var_dump($thing);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Before call by ref: array(2) { [0]=> int(1) [1]=> int(2) } Call by ref value: NULL After call by ref: array(3) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } } Before call by value Notice: Undefined offset: 7 in /in/uuDs6 on line 20 Call by value value: NULL After call by value: array(3) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } } Before call by ref again: Call by ref value: NULL After call by ref again: array(4) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } [7]=> array(1) { [8]=> NULL } }
Output for hhvm-3.10.0 - 3.12.0
Before call by ref: array(2) { [0]=> int(1) [1]=> int(2) } Call by ref value: NULL After call by ref: array(3) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } } Before call by value Notice: Undefined index: 7 in /in/uuDs6 on line 20 Call by value value: NULL After call by value: array(3) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } } Before call by ref again: Call by ref value: NULL After call by ref again: array(4) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } [7]=> array(1) { [8]=> NULL } }
Output for 4.3.0 - 5.2.17
Before call by ref: array(2) { [0]=> int(1) [1]=> int(2) } Call by ref value: NULL After call by ref: array(3) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } } Before call by value Notice: Undefined offset: 7 in /in/uuDs6 on line 20 Call by value value: NULL After call by value: array(3) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } } Before call by ref again: Call by ref value: NULL After call by ref again: array(4) { [0]=> int(1) [1]=> int(2) [5]=> array(1) { [6]=> NULL } [7]=> array(1) { [8]=> NULL } }