3v4l.org

run code in 300+ PHP versions simultaneously
<?php $row = 'Foo'; echo "What is \$row?\n"; var_dump($row); $rows = ['Hello', 'Test', 'Wow']; echo "Lets print each value in \$rows as \$row by reference\n"; foreach($rows as &$row) { var_dump($row); } echo "Now lets run the same thing again, only this time not as reference\n"; foreach ($rows as $row) { var_dump($row); } echo "And print \$row for the sake of it\n"; var_dump($row);
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
What is $row? string(3) "Foo" Lets print each value in $rows as $row by reference string(5) "Hello" string(4) "Test" string(3) "Wow" Now lets run the same thing again, only this time not as reference string(5) "Hello" string(4) "Test" string(4) "Test" And print $row for the sake of it string(4) "Test"

preferences:
216.72 ms | 404 KiB | 283 Q