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