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