1--TEST--
2Test strip_tags() function : usage variations - unexpected values for 'allowable_tags'
3--FILE--
4<?php
5/*
6 * testing functionality of strip_tags() by giving unexpected values for $allowable_tags argument
7*/
8
9echo "*** Testing strip_tags() : usage variations ***\n";
10
11// Initialise function argument
12$string = "<html><a>hello</a></html><p>world</p><!-- COMMENT --><?php echo hello ?>";
13
14//get an unset variable
15$unset_var = 10;
16unset ($unset_var);
17
18//get a resource variable
19$fp = fopen(__FILE__, "r");
20
21//get a class
22class classA{
23   public function __toString(){
24     return "Class A Object";
25   }
26}
27
28//array of values to iterate over
29$values = array(
30
31      // int data
32      0,
33      1,
34      12345,
35      -2345,
36
37      // float data
38      10.5,
39      -10.5,
40      10.5e10,
41      10.6E-10,
42      .5,
43
44      // null data
45      NULL,
46      null,
47
48      // boolean data
49      true,
50      false,
51      TRUE,
52      FALSE,
53
54      // empty data
55      "",
56      '',
57
58      // object data
59      new classA(),
60
61      // undefined data
62      @$undefined_var,
63
64      // unset data
65      @$unset_var,
66
67      // resource variable
68      $fp
69);
70
71// loop through each element of the array for allowable_tags
72$iterator = 1;
73foreach($values as $value) {
74      echo "-- Iteration $iterator --\n";
75      try {
76        var_dump(strip_tags($string, $value));
77      } catch (TypeError $exception) {
78        echo $exception->getMessage() . "\n";
79      }
80      $iterator++;
81};
82
83echo "Done";
84?>
85--EXPECT--
86*** Testing strip_tags() : usage variations ***
87-- Iteration 1 --
88string(10) "helloworld"
89-- Iteration 2 --
90string(10) "helloworld"
91-- Iteration 3 --
92string(10) "helloworld"
93-- Iteration 4 --
94string(10) "helloworld"
95-- Iteration 5 --
96string(10) "helloworld"
97-- Iteration 6 --
98string(10) "helloworld"
99-- Iteration 7 --
100string(10) "helloworld"
101-- Iteration 8 --
102string(10) "helloworld"
103-- Iteration 9 --
104string(10) "helloworld"
105-- Iteration 10 --
106string(10) "helloworld"
107-- Iteration 11 --
108string(10) "helloworld"
109-- Iteration 12 --
110string(10) "helloworld"
111-- Iteration 13 --
112string(10) "helloworld"
113-- Iteration 14 --
114string(10) "helloworld"
115-- Iteration 15 --
116string(10) "helloworld"
117-- Iteration 16 --
118string(10) "helloworld"
119-- Iteration 17 --
120string(10) "helloworld"
121-- Iteration 18 --
122string(10) "helloworld"
123-- Iteration 19 --
124string(10) "helloworld"
125-- Iteration 20 --
126string(10) "helloworld"
127-- Iteration 21 --
128strip_tags(): Argument #2 ($allowed_tags) must be of type array|string|null, resource given
129Done
130