3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit
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 Warning: Undefined array key 7 in /in/uuDs6 on line 20 Warning: Trying to access array offset on value of type null 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 rfc.property-hooks
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 Warning: Undefined array key 7 in /in/uuDs6 on line 20 Warning: Trying to access array offset on null 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 } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.15 ms | 402 KiB | 8 Q