3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dtArray = array(); $dtArray[] = new DateTime(); $dtArray[] = new DateTime(); foreach($dtArray as $value) { $value = null; } echo "object NOT reference: \n"; var_dump($dtArray); $dtArrayRef = array(); $dtArrayRef[] = new DateTime(); $dtArrayRef[] = new DateTime(); foreach($dtArrayRef as &$value) { $value = null; } echo "object REFERENCE: \n" var_dump($dtArrayRef); $string = array(); $string[] = 'new DateTime();'; $string[] = 'new DateTime();'; foreach($string as $value) { $value = null; } echo "string NOT reference: \n" var_dump($string);
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
Parse error: syntax error, unexpected 'var_dump' (T_STRING), expecting ',' or ';' in /in/fU5oH on line 35
Process exited with code 255.

preferences:
177.93 ms | 1395 KiB | 22 Q