3v4l.org

run code in 300+ PHP versions simultaneously
<?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.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
["<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.0.5, 5.1.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.3.11, 4.4.0 - 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

preferences:
334.79 ms | 401 KiB | 460 Q