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