3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if(version_compare(PHP_VERSION, '5.3') < 0) { echo 'unsupported version'; return; } $j0 = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; $j1 = $j0 | JSON_FORCE_OBJECT; foreach( array( array() ) as $i) { echo json_encode($foo, JSON_FORCE_OBJECT); }
based on 9Q2T5
Output for 7.1.0
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/aB4Eg on line 8 Warning: A non-numeric value encountered in /in/aB4Eg on line 8 Notice: Undefined variable: foo in /in/aB4Eg on line 15 null
Output for 5.3.0 - 7.0.14
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/aB4Eg on line 8 Notice: Undefined variable: foo in /in/aB4Eg on line 15 null
Output for 4.3.0 - 5.2.17
unsupported version