3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(1, 1); $a = &$arr[0]; $a++; //'$a' and '$arr[0]' point to the same reference. echo '$arr:' . "\n"; var_dump($arr); echo '$a:' . "\n"; var_dump($a); echo PHP_EOL . PHP_EOL; $arr2 = $arr; $arr2[0]++; $arr2[1]++; //Even though you didn't assigned '$arr' to '$arr2' by reference, the first element keeps the reference to the original value. Now '$arr[0]', '$a' and '$arr2[0]' point all to the same reference. //But the second element won't change for the '$arr' array echo '$arr:' . "\n"; var_dump($arr); echo '$arr2:' . "\n"; var_dump($arr2);
Output for git.master, git.master_jit, rfc.property-hooks
$arr: array(2) { [0]=> &int(2) [1]=> int(1) } $a: int(2) $arr: array(2) { [0]=> &int(3) [1]=> int(1) } $arr2: array(2) { [0]=> &int(3) [1]=> int(2) }

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:
30.82 ms | 401 KiB | 8 Q