3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $tx = ["ans1","ans2","ans3"]; $o = []; for ($i=0, $max = 3; $i < $max; $i++) { $o[] = new stdClass; $o[]->text = tx[$i]; } print_r( $o );
Output for 7.2.0 - 7.3.0rc4
Warning: Use of undefined constant tx - assumed 'tx' (this will throw an Error in a future version of PHP) in /in/kjdRE on line 8 Warning: Creating default object from empty value in /in/kjdRE on line 8 Warning: Use of undefined constant tx - assumed 'tx' (this will throw an Error in a future version of PHP) in /in/kjdRE on line 8 Warning: Creating default object from empty value in /in/kjdRE on line 8 Warning: Use of undefined constant tx - assumed 'tx' (this will throw an Error in a future version of PHP) in /in/kjdRE on line 8 Notice: Uninitialized string offset: 2 in /in/kjdRE on line 8 Warning: Creating default object from empty value in /in/kjdRE on line 8 Array ( [0] => stdClass Object ( ) [1] => stdClass Object ( [text] => t ) [2] => stdClass Object ( ) [3] => stdClass Object ( [text] => x ) [4] => stdClass Object ( ) [5] => stdClass Object ( [text] => ) )
Output for 5.6.0 - 5.6.38, hhvm-3.15.4 - 3.21.3, 7.0.0 - 7.1.23
Notice: Use of undefined constant tx - assumed 'tx' in /in/kjdRE on line 8 Warning: Creating default object from empty value in /in/kjdRE on line 8 Notice: Use of undefined constant tx - assumed 'tx' in /in/kjdRE on line 8 Warning: Creating default object from empty value in /in/kjdRE on line 8 Notice: Use of undefined constant tx - assumed 'tx' in /in/kjdRE on line 8 Notice: Uninitialized string offset: 2 in /in/kjdRE on line 8 Warning: Creating default object from empty value in /in/kjdRE on line 8 Array ( [0] => stdClass Object ( ) [1] => stdClass Object ( [text] => t ) [2] => stdClass Object ( ) [3] => stdClass Object ( [text] => x ) [4] => stdClass Object ( ) [5] => stdClass Object ( [text] => ) )
Output for hhvm-3.22.0
Notice: Use of undefined constant tx - assumed 'tx' in /in/kjdRE on line -1 Warning: Creating default object from empty value in /in/kjdRE on line -1 Notice: Use of undefined constant tx - assumed 'tx' in /in/kjdRE on line -1 Warning: Creating default object from empty value in /in/kjdRE on line -1 Notice: Use of undefined constant tx - assumed 'tx' in /in/kjdRE on line -1 Notice: Uninitialized string offset: 2 in /in/kjdRE on line -1 Warning: Creating default object from empty value in /in/kjdRE on line -1 Array ( [0] => stdClass Object ( ) [1] => stdClass Object ( [text] => t ) [2] => stdClass Object ( ) [3] => stdClass Object ( [text] => x ) [4] => stdClass Object ( ) [5] => stdClass Object ( [text] => ) )