3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $test = [ #ints 0,1,2,-1,-2, #floats 0.0,0.1,0.2,1.0,1.1,2.0,2.1, -0.1,-0.2,-1.0,-1.1,-2.0,-2.1, #strings "", "a", "0","@","NULL", #bool true, false, #array [], ["a"],[[]], #object new stdClass, #null NULL,"\0", function(){}, ]; foreach($test as $k => $v){ if(is_scalar($v)){ $j = $k + 97; ${$j} = new stdClass; ${$j}->${$j} = $v; $test[] = ${$j}; } } print_r($test);
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class stdClass could not be converted to string in /in/NnZnq on line 26
Process exited with code 255.
Output for 5.4.10 - 7.0.20
Catchable fatal error: Object of class stdClass could not be converted to string in /in/NnZnq on line 26
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/NnZnq on line 3
Process exited with code 255.