1--TEST--
2Test htmlspecialchars_decode() function : usage variations - unexpected values for 'quote_style' 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() by giving unexpected input values for $quote_style argument
12*/
13
14echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
15
16// Initialise function arguments
17// value initialized = Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "
18$string = "<html>Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 15. 1111 &amp; 0000 = 0000. &quot; double quote string &quot;</html>";
19
20//get a class
21class classA {
22  function __toString() {
23    return "Class A Object";
24  }
25}
26
27//get a resource variable
28$file_handle = fopen(__FILE__, "r");
29
30//get an unset variable
31$unset_var = 10;
32unset($unset_var);
33
34//array of values to iterate over
35$values = array(
36
37      // float data
38      10.5,
39      -10.5,
40      10.5e20,
41      10.6E-10,
42      .5,
43
44      // array data
45      array(),
46      array(0),
47      array(1),
48      array(1, 2),
49      array('color' => 'red', 'item' => 'pen'),
50
51      // null data
52      NULL,
53      null,
54
55      // boolean data
56      true,
57      false,
58      TRUE,
59      FALSE,
60
61      // empty data
62      "",
63      '',
64
65      // string data
66      "string",
67      'string',
68
69      // object data
70      new classA(),
71
72      // undefined data
73      @$undefined_var,
74
75      // unset data
76      @$unset_var,
77
78      //resource
79      $file_handle
80);
81
82// loop through each element of the array for quote_style
83$iterator = 1;
84foreach($values as $value) {
85      echo "\n-- Iteration $iterator --\n";
86      var_dump( htmlspecialchars_decode($string, $value) );
87      $iterator++;
88}
89
90// close the file resource used
91fclose($file_handle);
92
93echo "Done";
94?>
95--EXPECTF--
96*** Testing htmlspecialchars_decode() : usage variations ***
97
98-- Iteration 1 --
99string(104) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
100
101-- Iteration 2 --
102string(104) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"
103
104-- Iteration 3 --
105
106Warning: htmlspecialchars_decode() expects parameter 2 to be integer, float given in %s on line %d
107NULL
108
109-- Iteration 4 --
110string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
111
112-- Iteration 5 --
113string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
114
115-- Iteration 6 --
116
117Warning: htmlspecialchars_decode() expects parameter 2 to be integer, array given in %shtmlspecialchars_decode_variation2.php on line %d
118NULL
119
120-- Iteration 7 --
121
122Warning: htmlspecialchars_decode() expects parameter 2 to be integer, array given in %shtmlspecialchars_decode_variation2.php on line %d
123NULL
124
125-- Iteration 8 --
126
127Warning: htmlspecialchars_decode() expects parameter 2 to be integer, array given in %shtmlspecialchars_decode_variation2.php on line %d
128NULL
129
130-- Iteration 9 --
131
132Warning: htmlspecialchars_decode() expects parameter 2 to be integer, array given in %shtmlspecialchars_decode_variation2.php on line %d
133NULL
134
135-- Iteration 10 --
136
137Warning: htmlspecialchars_decode() expects parameter 2 to be integer, array given in %shtmlspecialchars_decode_variation2.php on line %d
138NULL
139
140-- Iteration 11 --
141string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
142
143-- Iteration 12 --
144string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
145
146-- Iteration 13 --
147string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
148
149-- Iteration 14 --
150string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
151
152-- Iteration 15 --
153string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
154
155-- Iteration 16 --
156string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
157
158-- Iteration 17 --
159
160Warning: htmlspecialchars_decode() expects parameter 2 to be integer, string given in %shtmlspecialchars_decode_variation2.php on line %d
161NULL
162
163-- Iteration 18 --
164
165Warning: htmlspecialchars_decode() expects parameter 2 to be integer, string given in %shtmlspecialchars_decode_variation2.php on line %d
166NULL
167
168-- Iteration 19 --
169
170Warning: htmlspecialchars_decode() expects parameter 2 to be integer, string given in %shtmlspecialchars_decode_variation2.php on line %d
171NULL
172
173-- Iteration 20 --
174
175Warning: htmlspecialchars_decode() expects parameter 2 to be integer, string given in %shtmlspecialchars_decode_variation2.php on line %d
176NULL
177
178-- Iteration 21 --
179
180Warning: htmlspecialchars_decode() expects parameter 2 to be integer, object given in %shtmlspecialchars_decode_variation2.php on line %d
181NULL
182
183-- Iteration 22 --
184string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
185
186-- Iteration 23 --
187string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 = 0000. &quot; double quote string &quot;</html>"
188
189-- Iteration 24 --
190
191Warning: htmlspecialchars_decode() expects parameter 2 to be integer, resource given in %shtmlspecialchars_decode_variation2.php on line %d
192NULL
193Done
194