1--TEST--
2Test htmlspecialchars_decode() function : basic functionality
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
10echo "*** Testing htmlspecialchars_decode() : basic functionality ***\n";
11
12
13// Initialise arguments
14//value initialized = Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. "double quoted string"
15$single_quote_string = "Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 25. 1111 &amp; 0000 = 0000. &quot; double quoted string &quot;";
16$double_quote_string = "Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 25. 1111 &amp; 0000 = 0000. &quot; double quoted string &quot;";
17
18// Calling htmlspecialchars_decode() with default arguments
19var_dump( htmlspecialchars_decode($single_quote_string) );
20var_dump( htmlspecialchars_decode($double_quote_string) );
21
22// Calling htmlspecialchars_decode() with optional 'quote_style' argument
23var_dump( htmlspecialchars_decode($single_quote_string, ENT_COMPAT) );
24var_dump( htmlspecialchars_decode($double_quote_string, ENT_COMPAT) );
25var_dump( htmlspecialchars_decode($single_quote_string, ENT_NOQUOTES) );
26var_dump( htmlspecialchars_decode($double_quote_string, ENT_NOQUOTES) );
27var_dump( htmlspecialchars_decode($single_quote_string, ENT_QUOTES) );
28var_dump( htmlspecialchars_decode($double_quote_string, ENT_QUOTES) );
29
30echo "Done";
31?>
32--EXPECT--
33*** Testing htmlspecialchars_decode() : basic functionality ***
34string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
35string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
36string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
37string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
38string(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. &quot; double quoted string &quot;"
39string(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 0000. &quot; double quoted string &quot;"
40string(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
41string(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " double quoted string ""
42Done
43