3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php phpversion() >= "7.0.0" or die(); $foo = 'foo'; $bar = new stdClass; $bar->$foo = array(10, 20, 30); // $bar->foo => array(10, 20, 30) $bar->{$foo[0]} = 42; // dynamic prop $f = 42 fr 0 offset of ‘foo’ $bar->$foo[0] = 42; // zeroth element of array $foo set to 42 print_r($bar);
based on Xe86F
Output for 7.0.0 - 7.2.0
stdClass Object ( [foo] => Array ( [0] => 42 [1] => 20 [2] => 30 ) [f] => 42 )
Output for 5.3.21 - 5.6.28