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