3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array('<foo>',"'bar'",'"baz"','&blong&', "\xc3\xa9"); echo json_encode($a), "\n"; echo "Tags: ", json_encode($a, JSON_HEX_TAG), "\n"; echo "Apos: ", json_encode($a, JSON_HEX_APOS), "\n"; echo "Quot: ", json_encode($a, JSON_HEX_QUOT), "\n"; echo "Amp: ", json_encode($a, JSON_HEX_AMP), "\n"; echo "Unicode: ", json_encode($a, JSON_UNESCAPED_UNICODE), "\n";
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.14.4, 7.0.0 - 7.1.0
["<foo>","'bar'","\"baz\"","&blong&","\u00e9"] Tags: ["\u003Cfoo\u003E","'bar'","\"baz\"","&blong&","\u00e9"] Apos: ["<foo>","\u0027bar\u0027","\"baz\"","&blong&","\u00e9"] Quot: ["<foo>","'bar'","\u0022baz\u0022","&blong&","\u00e9"] Amp: ["<foo>","'bar'","\"baz\"","\u0026blong\u0026","\u00e9"] Unicode: ["<foo>","'bar'","\"baz\"","&blong&","é"]
Output for 5.3.0 - 5.3.29
["<foo>","'bar'","\"baz\"","&blong&","\u00e9"] Tags: ["\u003Cfoo\u003E","'bar'","\"baz\"","&blong&","\u00e9"] Apos: ["<foo>","\u0027bar\u0027","\"baz\"","&blong&","\u00e9"] Quot: ["<foo>","'bar'","\u0022baz\u0022","&blong&","\u00e9"] Amp: ["<foo>","'bar'","\"baz\"","\u0026blong\u0026","\u00e9"] Unicode: Notice: Use of undefined constant JSON_UNESCAPED_UNICODE - assumed 'JSON_UNESCAPED_UNICODE' in /in/RjvYg on line 9 Warning: json_encode() expects parameter 2 to be long, string given in /in/RjvYg on line 9
Output for 5.2.0 - 5.2.17
["<foo>","'bar'","\"baz\"","&blong&","\u00e9"] Tags: Notice: Use of undefined constant JSON_HEX_TAG - assumed 'JSON_HEX_TAG' in /in/RjvYg on line 5 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/RjvYg on line 5 Apos: Notice: Use of undefined constant JSON_HEX_APOS - assumed 'JSON_HEX_APOS' in /in/RjvYg on line 6 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/RjvYg on line 6 Quot: Notice: Use of undefined constant JSON_HEX_QUOT - assumed 'JSON_HEX_QUOT' in /in/RjvYg on line 7 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/RjvYg on line 7 Amp: Notice: Use of undefined constant JSON_HEX_AMP - assumed 'JSON_HEX_AMP' in /in/RjvYg on line 8 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/RjvYg on line 8 Unicode: Notice: Use of undefined constant JSON_UNESCAPED_UNICODE - assumed 'JSON_UNESCAPED_UNICODE' in /in/RjvYg on line 9 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/RjvYg on line 9
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/RjvYg on line 4
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/RjvYg on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/RjvYg on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/RjvYg on line 4