3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if(!defined('JSON_FORCE_OBJECT') < 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($i, JSON_FORCE_OBJECT); }
based on aB4Eg
Output for 7.2.0 - 7.2.6
Warning: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' (this will throw an Error in a future version of PHP) in /in/9inBU on line 8 Warning: A non-numeric value encountered in /in/9inBU on line 8 {}
Output for 7.1.0 - 7.1.20
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/9inBU on line 8 Warning: A non-numeric value encountered in /in/9inBU on line 8 {}
Output for 5.3.0 - 7.0.20
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/9inBU on line 8 {}
Output for 5.2.0 - 5.2.17
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/9inBU on line 8 Notice: Use of undefined constant JSON_FORCE_OBJECT - assumed 'JSON_FORCE_OBJECT' in /in/9inBU on line 15 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/9inBU on line 15
Output for 5.0.0 - 5.1.6
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/9inBU on line 8 Fatal error: Call to undefined function json_encode() in /in/9inBU on line 15
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/9inBU on line 8 Fatal error: Call to undefined function: json_encode() in /in/9inBU on line 15
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/9inBU on line 8 Fatal error: Call to undefined function: json_encode() in /in/9inBU on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant  JSON_FORCE_OBJECT - assumed ' JSON_FORCE_OBJECT' in /in/9inBU on line 8 Fatal error: Call to undefined function: json_encode() in /in/9inBU on line 15