1--TEST--
2Test htmlspecialchars_decode() function : usage variations - double quoted strings for 'string' argument
3--FILE--
4<?php
5/* Prototype  : string htmlspecialchars_decode(string $string [, int $quote_style])
6 * Description: Convert special HTML entities back to characters
7 * Source code: ext/standard/html.c
8*/
9
10/*
11 * testing htmlspecialchars_decode() for various double quoted strings as argument for $string
12*/
13echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
14
15//double quoted strings
16$strings = array (
17  "Roy&#039s height &gt; Sam&#039;s \$height... 1111 &ap; 0000 = 0000... &quot; double quote string &quot;",
18  "Roy&#039;s height &gt; Sam&#039;s height... \t\t 13 &lt; 15...\n\r &quot; double quote\f\v string &quot;",
19  "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f",
20  "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height",
21  "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12",
22);
23
24// loop through each element of the array to check htmlspecialchars_decode() function with all possible arguments
25$iterator = 1;
26foreach($strings as $value) {
27      echo "-- Iteration $iterator --\n";
28      var_dump( htmlspecialchars_decode($value) );
29      var_dump( htmlspecialchars_decode($value, ENT_COMPAT) );
30      var_dump( htmlspecialchars_decode($value, ENT_NOQUOTES) );
31      var_dump( htmlspecialchars_decode($value, ENT_QUOTES) );
32      $iterator++;
33}
34
35echo "Done";
36?>
37--EXPECTF--
38*** Testing htmlspecialchars_decode() : usage variations ***
39-- Iteration 1 --
40string(89) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... " double quote string ""
41string(89) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... " double quote string ""
42string(99) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... &quot; double quote string &quot;"
43string(84) "Roy&#039s height > Sam's $height... 1111 &ap; 0000 = 0000... " double quote string ""
44-- Iteration 2 --
45string(82) "Roy&#039;s height > Sam&#039;s height... 		 13 < 15...
46
46 " double quote string ""
47string(82) "Roy&#039;s height > Sam&#039;s height... 		 13 < 15...
48
48 " double quote string ""
49string(92) "Roy&#039;s height > Sam&#039;s height... 		 13 < 15...
50
50 &quot; double quote string &quot;"
51string(72) "Roy's height > Sam's height... 		 13 < 15...
52
52 " double quote string ""
53-- Iteration 3 --
54string(44) "
55Roy&#039;s height &gt	; Sam&#039;s height"
56string(44) "
57Roy&#039;s height &gt	; Sam&#039;s height"
58string(44) "
59Roy&#039;s height &gt	; Sam&#039;s height"
60string(34) "
61Roy's height &gt	; Sam's height"
62-- Iteration 4 --
63string(44) "
63	Roy&#039;s height &gt
63; Sam	&#039;s height"
64string(44) "
64	Roy&#039;s height &gt
64; Sam	&#039;s height"
65string(44) "
65	Roy&#039;s height &gt
65; Sam	&#039;s height"
66string(34) "
66	Roy's height &gt
66; Sam	's height"
67-- Iteration 5 --
68string(30) "
69 1	3 &	gt; 11 but 11 &	lt; 12"
70string(30) "
71 1	3 &	gt; 11 but 11 &	lt; 12"
72string(30) "
73 1	3 &	gt; 11 but 11 &	lt; 12"
74string(30) "
75 1	3 &	gt; 11 but 11 &	lt; 12"
76Done