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