1--TEST--
2Test current() function : usage variations - Pass different data types as $array_arg arg
3--FILE--
4<?php
5/* Prototype  : mixed current(array $array_arg)
6 * Description: Return the element currently pointed to by the internal array pointer
7 * Source code: ext/standard/array.c
8 * Alias to functions: pos
9 */
10
11/*
12 * Pass different data types as $array_arg argument to current() to test behaviour
13 */
14
15echo "*** Testing current() : usage variations ***\n";
16
17//get an unset variable
18$unset_var = 10;
19unset ($unset_var);
20
21// get a class
22class classA
23{
24	var $var1;
25  public function __toString() {
26    return "Class A object";
27  }
28}
29
30// heredoc string
31$heredoc = <<<EOT
32hello world
33EOT;
34
35// get a resource variable
36$fp = fopen(__FILE__, "r");
37
38// unexpected values to be passed to $array_arg argument
39$inputs = array(
40
41       // int data
42/*1*/  0,
43       1,
44       12345,
45       -2345,
46
47       // float data
48/*5*/  10.5,
49       -10.5,
50       12.3456789000e10,
51       12.3456789000E-10,
52       .5,
53
54       // null data
55/*10*/ NULL,
56       null,
57
58       // boolean data
59/*12*/ true,
60       false,
61       TRUE,
62       FALSE,
63
64       // empty data
65/*16*/ "",
66       '',
67
68       // string data
69/*18*/ "string",
70       'string',
71       $heredoc,
72
73       // object data
74/*21*/ new classA(),
75
76       // undefined data
77/*22*/ @$undefined_var,
78
79       // unset data
80/*23*/ @$unset_var,
81
82       // resource variable
83/*24*/ $fp
84);
85
86// loop through each element of $inputs to check the behavior of current()
87$iterator = 1;
88foreach($inputs as $input) {
89  echo "\n-- Iteration $iterator --\n";
90  var_dump( current($input) );
91  $iterator++;
92};
93
94fclose($fp);
95?>
96===DONE===
97--EXPECTF--
98*** Testing current() : usage variations ***
99
100-- Iteration 1 --
101
102Warning: current() expects parameter 1 to be array, integer given in %s on line %d
103NULL
104
105-- Iteration 2 --
106
107Warning: current() expects parameter 1 to be array, integer given in %s on line %d
108NULL
109
110-- Iteration 3 --
111
112Warning: current() expects parameter 1 to be array, integer given in %s on line %d
113NULL
114
115-- Iteration 4 --
116
117Warning: current() expects parameter 1 to be array, integer given in %s on line %d
118NULL
119
120-- Iteration 5 --
121
122Warning: current() expects parameter 1 to be array, float given in %s on line %d
123NULL
124
125-- Iteration 6 --
126
127Warning: current() expects parameter 1 to be array, float given in %s on line %d
128NULL
129
130-- Iteration 7 --
131
132Warning: current() expects parameter 1 to be array, float given in %s on line %d
133NULL
134
135-- Iteration 8 --
136
137Warning: current() expects parameter 1 to be array, float given in %s on line %d
138NULL
139
140-- Iteration 9 --
141
142Warning: current() expects parameter 1 to be array, float given in %s on line %d
143NULL
144
145-- Iteration 10 --
146
147Warning: current() expects parameter 1 to be array, null given in %s on line %d
148NULL
149
150-- Iteration 11 --
151
152Warning: current() expects parameter 1 to be array, null given in %s on line %d
153NULL
154
155-- Iteration 12 --
156
157Warning: current() expects parameter 1 to be array, boolean given in %s on line %d
158NULL
159
160-- Iteration 13 --
161
162Warning: current() expects parameter 1 to be array, boolean given in %s on line %d
163NULL
164
165-- Iteration 14 --
166
167Warning: current() expects parameter 1 to be array, boolean given in %s on line %d
168NULL
169
170-- Iteration 15 --
171
172Warning: current() expects parameter 1 to be array, boolean given in %s on line %d
173NULL
174
175-- Iteration 16 --
176
177Warning: current() expects parameter 1 to be array, string given in %s on line %d
178NULL
179
180-- Iteration 17 --
181
182Warning: current() expects parameter 1 to be array, string given in %s on line %d
183NULL
184
185-- Iteration 18 --
186
187Warning: current() expects parameter 1 to be array, string given in %s on line %d
188NULL
189
190-- Iteration 19 --
191
192Warning: current() expects parameter 1 to be array, string given in %s on line %d
193NULL
194
195-- Iteration 20 --
196
197Warning: current() expects parameter 1 to be array, string given in %s on line %d
198NULL
199
200-- Iteration 21 --
201NULL
202
203-- Iteration 22 --
204
205Warning: current() expects parameter 1 to be array, null given in %s on line %d
206NULL
207
208-- Iteration 23 --
209
210Warning: current() expects parameter 1 to be array, null given in %s on line %d
211NULL
212
213-- Iteration 24 --
214
215Warning: current() expects parameter 1 to be array, resource given in %s on line %d
216NULL
217===DONE===
218