xref: /PHP-8.2/ext/json/tests/006.phpt (revision 32a1ebbd)
1--TEST--
2json_encode() & extended encoding
3--FILE--
4<?php
5$a = array('<foo>', "'bar'", '"baz"', '&blong&');
6
7echo "Normal: ", json_encode($a), "\n";
8echo "Tags: ",   json_encode($a, JSON_HEX_TAG), "\n";
9echo "Apos: ",   json_encode($a, JSON_HEX_APOS), "\n";
10echo "Quot: ",   json_encode($a, JSON_HEX_QUOT), "\n";
11echo "Amp: ",    json_encode($a, JSON_HEX_AMP), "\n";
12echo "All: ",    json_encode($a, JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP), "\n";
13?>
14--EXPECT--
15Normal: ["<foo>","'bar'","\"baz\"","&blong&"]
16Tags: ["\u003Cfoo\u003E","'bar'","\"baz\"","&blong&"]
17Apos: ["<foo>","\u0027bar\u0027","\"baz\"","&blong&"]
18Quot: ["<foo>","'bar'","\u0022baz\u0022","&blong&"]
19Amp: ["<foo>","'bar'","\"baz\"","\u0026blong\u0026"]
20All: ["\u003Cfoo\u003E","\u0027bar\u0027","\u0022baz\u0022","\u0026blong\u0026"]
21