1--TEST--
2Test strip_tags() function : usage variations - unexpected values for 'allowable_tags'
3--INI--
4short_open_tag = on
5--FILE--
6<?php
7/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
8 * Description: Strips HTML and PHP tags from a string
9 * Source code: ext/standard/string.c
10*/
11
12/*
13 * testing functionality of strip_tags() by giving unexpected values for $allowable_tags argument
14*/
15
16echo "*** Testing strip_tags() : usage variations ***\n";
17
18// Initialise function argument
19$string = "<html><a>hello</a></html><p>world</p><!-- COMMENT --><?php echo hello ?>";
20
21//get an unset variable
22$unset_var = 10;
23unset ($unset_var);
24
25//get a resource variable
26$fp = fopen(__FILE__, "r");
27
28//get a class
29class classA{
30   public function __toString(){
31     return "Class A Object";
32   }
33}
34
35//array of values to iterate over
36$values = array(
37
38      // int data
39      0,
40      1,
41      12345,
42      -2345,
43
44      // float data
45      10.5,
46      -10.5,
47      10.5e10,
48      10.6E-10,
49      .5,
50
51      // array data
52      array(),
53      array(0),
54      array(1),
55      array(1, 2),
56      array('color' => 'red', 'item' => 'pen'),
57
58      // null data
59      NULL,
60      null,
61
62      // boolean data
63      true,
64      false,
65      TRUE,
66      FALSE,
67
68      // empty data
69      "",
70      '',
71
72      // object data
73      new classA(),
74
75      // undefined data
76      @$undefined_var,
77
78      // unset data
79      @$unset_var,
80
81      // resource variable
82      $fp
83);
84
85// loop through each element of the array for allowable_tags
86$iterator = 1;
87foreach($values as $value) {
88      echo "-- Iteration $iterator --\n";
89      var_dump( strip_tags($string, $value) );
90      $iterator++;
91};
92
93echo "Done";
94?>
95--EXPECTF--
96*** Testing strip_tags() : usage variations ***
97-- Iteration 1 --
98string(10) "helloworld"
99-- Iteration 2 --
100string(10) "helloworld"
101-- Iteration 3 --
102string(10) "helloworld"
103-- Iteration 4 --
104string(10) "helloworld"
105-- Iteration 5 --
106string(10) "helloworld"
107-- Iteration 6 --
108string(10) "helloworld"
109-- Iteration 7 --
110string(10) "helloworld"
111-- Iteration 8 --
112string(10) "helloworld"
113-- Iteration 9 --
114string(10) "helloworld"
115-- Iteration 10 --
116
117Notice: Array to string conversion in %s on line %d
118string(10) "helloworld"
119-- Iteration 11 --
120
121Notice: Array to string conversion in %s on line %d
122string(10) "helloworld"
123-- Iteration 12 --
124
125Notice: Array to string conversion in %s on line %d
126string(10) "helloworld"
127-- Iteration 13 --
128
129Notice: Array to string conversion in %s on line %d
130string(10) "helloworld"
131-- Iteration 14 --
132
133Notice: Array to string conversion in %s on line %d
134string(10) "helloworld"
135-- Iteration 15 --
136string(10) "helloworld"
137-- Iteration 16 --
138string(10) "helloworld"
139-- Iteration 17 --
140string(10) "helloworld"
141-- Iteration 18 --
142string(10) "helloworld"
143-- Iteration 19 --
144string(10) "helloworld"
145-- Iteration 20 --
146string(10) "helloworld"
147-- Iteration 21 --
148string(10) "helloworld"
149-- Iteration 22 --
150string(10) "helloworld"
151-- Iteration 23 --
152string(10) "helloworld"
153-- Iteration 24 --
154string(10) "helloworld"
155-- Iteration 25 --
156string(10) "helloworld"
157-- Iteration 26 --
158string(10) "helloworld"
159Done
160