1--TEST--
2Test htmlspecialchars_decode() function : usage variations - heredoc 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 heredoc strings as argument for $string
12*/
13
14echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
15
16// empty heredoc string
17$empty_string = <<<EOT
18EOT;
19
20// Heredoc string with blank line
21$blank_line = <<<EOT
22
23EOT;
24
25// heredoc with multiline string
26$multiline_string = <<<EOT
27<html>Roy&#039;s height &gt; Sam&#039;s height
2813 &lt; 25
291111 &amp; 0000 = 0000
30&quot;This is a double quoted string&quot;
31EOT;
32
33// heredoc with different whitespaces
34$diff_whitespaces = <<<EOT
35<html>Roy&#039;s height\r &gt; Sam\t&#039;s height
361111\t\t &amp; 0000\v\v = \f0000
37&quot; heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces&quot;
38EOT;
39
40// heredoc with numeric values
41$numeric_string = <<<EOT
42<html>11 &lt; 12. 123 string 4567
43&quot;string&quot; 1111\t &amp; 0000\t = 0000\n;
44EOT;
45
46// heredoc with quote chars & slash
47$quote_char_string = <<<EOT
48<html>&lt; This's a string with quotes:
49"strings in double quote" &amp;
50'strings in single quote' &quot;
51this\line is &#039;single quoted&#039; /with\slashes </html>
52EOT;
53
54$res_heredoc_strings = array(
55  //heredoc strings
56  $empty_string,
57  $blank_line,
58  $multiline_string,
59  $diff_whitespaces,
60  $numeric_string,
61  $quote_char_string
62);
63
64// loop through $res_heredoc_strings array and check the working on htmlspecialchars_decode()
65$count = 1;
66for($index =0; $index < count($res_heredoc_strings); $index ++) {
67  echo "-- Iteration $count --\n";
68  var_dump( htmlspecialchars_decode($res_heredoc_strings[$index]) );
69  $count++;
70}
71
72echo "Done\n";
73?>
74--EXPECTF--
75*** Testing htmlspecialchars_decode() : usage variations ***
76-- Iteration 1 --
77string(0) ""
78-- Iteration 2 --
79string(0) ""
80-- Iteration 3 --
81string(103) "<html>Roy&#039;s height > Sam&#039;s height
8213 < 25
831111 & 0000 = 0000
84"This is a double quoted string""
85-- Iteration 4 --
86string(130) "<html>Roy&#039;s height
86 > Sam	&#039;s height
871111		 & 0000 = 0000
88" heredoc
89double quoted string. withdifferentwhitespaces""
90-- Iteration 5 --
91string(62) "<html>11 < 12. 123 string 4567
92"string" 1111	 & 0000	 = 0000
93;"
94-- Iteration 6 --
95string(153) "<html>< This's a string with quotes:
96"strings in double quote" &
97'strings in single quote' "
98this\line is &#039;single quoted&#039; /with\slashes </html>"
99Done