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