1--TEST--
2Test htmlspecialchars_decode() function : usage variations - numerical entities for basic characters
3--FILE--
4<?php
5$tests = array(
6    "&quot;", "&#x22;", "&#34;",
7    "&apos;", "&#39;", "&#x27;",
8    "&amp;", "&#x26;", "&lt;",
9    "&gt;", "&#x3C;", "&#60;",
10    "&lt;", "&#x3E;", "&#62;",
11    "&#63;"
12);
13
14echo "*** HTML 4.01/ENT_QUOTES  ***\n";
15
16foreach ($tests as $t) {
17    $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_HTML401);
18    if ($t == $dec) {
19        echo "$t\tNOT DECODED\n";
20    } else {
21        echo "$t\tDECODED\n";
22    }
23}
24
25echo "\n*** XHTML 1.0/ENT_QUOTES  ***\n";
26
27foreach ($tests as $t) {
28    $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_XHTML);
29    if ($t == $dec) {
30        echo "$t\tNOT DECODED\n";
31    } else {
32        echo "$t\tDECODED\n";
33    }
34}
35
36echo "\n*** HTML5/ENT_QUOTES  ***\n";
37
38foreach ($tests as $t) {
39    $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_HTML5);
40    if ($t == $dec) {
41        echo "$t\tNOT DECODED\n";
42    } else {
43        echo "$t\tDECODED\n";
44    }
45}
46
47echo "\n*** XML 1.0/ENT_QUOTES  ***\n";
48
49foreach ($tests as $t) {
50    $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_XML1);
51    if ($t == $dec) {
52        echo "$t\tNOT DECODED\n";
53    } else {
54        echo "$t\tDECODED\n";
55    }
56}
57
58echo "\n*** HTML5/ENT_NOQUOTES  ***\n";
59
60foreach ($tests as $t) {
61    $dec = htmlspecialchars_decode($t, ENT_NOQUOTES | ENT_HTML5);
62    if ($t == $dec) {
63        echo "$t\tNOT DECODED\n";
64    } else {
65        echo "$t\tDECODED\n";
66    }
67}
68
69echo "\n*** HTML5/ENT_COMPAT  ***\n";
70
71foreach ($tests as $t) {
72    $dec = htmlspecialchars_decode($t, ENT_COMPAT | ENT_HTML5);
73    if ($t == $dec) {
74        echo "$t\tNOT DECODED\n";
75    } else {
76        echo "$t\tDECODED\n";
77    }
78}
79
80
81echo "\nDone.\n";
82?>
83--EXPECT--
84*** HTML 4.01/ENT_QUOTES  ***
85&quot;	DECODED
86&#x22;	DECODED
87&#34;	DECODED
88&apos;	NOT DECODED
89&#39;	DECODED
90&#x27;	DECODED
91&amp;	DECODED
92&#x26;	DECODED
93&lt;	DECODED
94&gt;	DECODED
95&#x3C;	DECODED
96&#60;	DECODED
97&lt;	DECODED
98&#x3E;	DECODED
99&#62;	DECODED
100&#63;	NOT DECODED
101
102*** XHTML 1.0/ENT_QUOTES  ***
103&quot;	DECODED
104&#x22;	DECODED
105&#34;	DECODED
106&apos;	DECODED
107&#39;	DECODED
108&#x27;	DECODED
109&amp;	DECODED
110&#x26;	DECODED
111&lt;	DECODED
112&gt;	DECODED
113&#x3C;	DECODED
114&#60;	DECODED
115&lt;	DECODED
116&#x3E;	DECODED
117&#62;	DECODED
118&#63;	NOT DECODED
119
120*** HTML5/ENT_QUOTES  ***
121&quot;	DECODED
122&#x22;	DECODED
123&#34;	DECODED
124&apos;	DECODED
125&#39;	DECODED
126&#x27;	DECODED
127&amp;	DECODED
128&#x26;	DECODED
129&lt;	DECODED
130&gt;	DECODED
131&#x3C;	DECODED
132&#60;	DECODED
133&lt;	DECODED
134&#x3E;	DECODED
135&#62;	DECODED
136&#63;	NOT DECODED
137
138*** XML 1.0/ENT_QUOTES  ***
139&quot;	DECODED
140&#x22;	DECODED
141&#34;	DECODED
142&apos;	DECODED
143&#39;	DECODED
144&#x27;	DECODED
145&amp;	DECODED
146&#x26;	DECODED
147&lt;	DECODED
148&gt;	DECODED
149&#x3C;	DECODED
150&#60;	DECODED
151&lt;	DECODED
152&#x3E;	DECODED
153&#62;	DECODED
154&#63;	NOT DECODED
155
156*** HTML5/ENT_NOQUOTES  ***
157&quot;	NOT DECODED
158&#x22;	NOT DECODED
159&#34;	NOT DECODED
160&apos;	NOT DECODED
161&#39;	NOT DECODED
162&#x27;	NOT DECODED
163&amp;	DECODED
164&#x26;	DECODED
165&lt;	DECODED
166&gt;	DECODED
167&#x3C;	DECODED
168&#60;	DECODED
169&lt;	DECODED
170&#x3E;	DECODED
171&#62;	DECODED
172&#63;	NOT DECODED
173
174*** HTML5/ENT_COMPAT  ***
175&quot;	DECODED
176&#x22;	DECODED
177&#34;	DECODED
178&apos;	NOT DECODED
179&#39;	NOT DECODED
180&#x27;	NOT DECODED
181&amp;	DECODED
182&#x26;	DECODED
183&lt;	DECODED
184&gt;	DECODED
185&#x3C;	DECODED
186&#60;	DECODED
187&lt;	DECODED
188&#x3E;	DECODED
189&#62;	DECODED
190&#63;	NOT DECODED
191
192Done.
193