1--TEST--
2Test stristr() function : usage variations - test values for $needle argument
3--FILE--
4<?php
5
6/* Prototype: string stristr ( string $haystack, string $needle );
7   Description: Case-insensitive strstr().
8*/
9
10echo "*** Testing stristr() function: with unexpected inputs for 'needle' argument ***\n";
11
12//get an unset variable
13$unset_var = 'string_val';
14unset($unset_var);
15
16//defining a class
17class sample  {
18  public function __toString() {
19    return "sample object";
20  }
21}
22
23//getting the resource
24$file_handle = fopen(__FILE__, "r");
25
26// array with different values for $input
27$inputs =  array (
28
29		  // integer values
30/*1*/	  0,
31		  1,
32		  -2,
33		  -PHP_INT_MAX,
34
35		  // float values
36/*5*/	  10.5,
37		  -20.5,
38		  10.1234567e10,
39
40		  // array values
41/*8*/	  array(),
42		  array(0),
43		  array(1, 2),
44
45		  // boolean values
46/*11*/	  true,
47		  false,
48		  TRUE,
49		  FALSE,
50
51		  // null values
52/*15*/	  NULL,
53		  null,
54
55		  // objects
56/*17*/	  new sample(),
57
58		  // resource
59/*18*/	  $file_handle,
60
61		  // undefined variable
62/*19*/	  @$undefined_var,
63
64		  // unset variable
65/*20*/	  @$unset_var
66);
67
68//defining '$pad_length' argument
69$pad_length = "20";
70
71// loop through with each element of the $inputs array to test stristr() function
72$count = 1;
73foreach($inputs as $input) {
74  echo "-- Iteration $count --\n";
75  var_dump( stristr("Hello World", $input) );
76  $count ++;
77}
78
79fclose($file_handle);  //closing the file handle
80
81?>
82===DONE===
83--EXPECTF--
84*** Testing stristr() function: with unexpected inputs for 'needle' argument ***
85-- Iteration 1 --
86
87Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
88bool(false)
89-- Iteration 2 --
90
91Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
92bool(false)
93-- Iteration 3 --
94
95Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
96bool(false)
97-- Iteration 4 --
98
99Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
100bool(false)
101-- Iteration 5 --
102
103Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
104bool(false)
105-- Iteration 6 --
106
107Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
108bool(false)
109-- Iteration 7 --
110
111Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
112bool(false)
113-- Iteration 8 --
114
115Warning: stristr(): needle is not a string or an integer in %s on line %d
116bool(false)
117-- Iteration 9 --
118
119Warning: stristr(): needle is not a string or an integer in %s on line %d
120bool(false)
121-- Iteration 10 --
122
123Warning: stristr(): needle is not a string or an integer in %s on line %d
124bool(false)
125-- Iteration 11 --
126
127Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
128bool(false)
129-- Iteration 12 --
130
131Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
132bool(false)
133-- Iteration 13 --
134
135Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
136bool(false)
137-- Iteration 14 --
138
139Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
140bool(false)
141-- Iteration 15 --
142
143Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
144bool(false)
145-- Iteration 16 --
146
147Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
148bool(false)
149-- Iteration 17 --
150
151Notice: Object of class sample could not be converted to int in %s on line %d
152
153Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
154bool(false)
155-- Iteration 18 --
156
157Warning: stristr(): needle is not a string or an integer in %s on line %d
158bool(false)
159-- Iteration 19 --
160
161Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
162bool(false)
163-- Iteration 20 --
164
165Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
166bool(false)
167===DONE===
168