Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / standard / tests / array / end_variation1.phpt
blob79354aba4f0f369f6c7c87bf8dabc02fe40c1dfe
1 --TEST--
2 Test end() function : usage variations - Pass different data types as $array_arg
3 --FILE--
4 <?php
5 /* Prototype  : mixed end(array $array_arg)
6  * Description: Advances array argument's internal pointer to the last element and return it 
7  * Source code: ext/standard/array.c
8  */
11  * Pass different data types as $array_arg to test behaviour of end()
12  */
14 echo "*** Testing end() : usage variations ***\n";
16 //get an unset variable
17 $unset_var = 10;
18 unset ($unset_var);
20 // get a class
21 class classA
23         var $foo = 'hello, world';
24         public function __toString() {
25                 return "Class A object";
26         }
29 // heredoc string
30 $heredoc = <<<EOT
31 hello world
32 EOT;
34 // get a resource variable
35 $fp = fopen(__FILE__, "r");
37 // unexpected values to be passed to $array_arg argument
38 $inputs = array(
40        // int data
41 /*1*/  0,
42        1,
43        12345,
44        -2345,
46        // float data
47 /*5*/  10.5,
48        -10.5,
49        12.3456789000e10,
50        12.3456789000E-10,
51        .5,
53        // null data
54 /*10*/ NULL,
55        null,
57        // boolean data
58 /*12*/ true,
59        false,
60        TRUE,
61        FALSE,
62        
63        // empty data
64 /*16*/ "",
65        '',
66        array(),
68        // string data
69 /*19*/ "string",
70        'string',
71        $heredoc,
72        
73        // object data
74 /*22*/ new classA(),
76        // undefined data
77 /*23*/ @$undefined_var,
79        // unset data
80 /*24*/ @$unset_var,
82        // resource variable
83 /*25*/ $fp
86 // loop through each element of $inputs to check the behavior of end()
87 $iterator = 1;
88 foreach($inputs as $input) {
89   echo "\n-- Iteration $iterator --\n";
90   var_dump( end($input) );
91   $iterator++;
94 fclose($fp);
96 ===DONE===
97 --EXPECTF--
98 *** Testing end() : usage variations ***
100 -- Iteration 1 --
102 Warning: end() expects parameter 1 to be array, integer given in %s on line %d
103 NULL
105 -- Iteration 2 --
107 Warning: end() expects parameter 1 to be array, integer given in %s on line %d
108 NULL
110 -- Iteration 3 --
112 Warning: end() expects parameter 1 to be array, integer given in %s on line %d
113 NULL
115 -- Iteration 4 --
117 Warning: end() expects parameter 1 to be array, integer given in %s on line %d
118 NULL
120 -- Iteration 5 --
122 Warning: end() expects parameter 1 to be array, double given in %s on line %d
123 NULL
125 -- Iteration 6 --
127 Warning: end() expects parameter 1 to be array, double given in %s on line %d
128 NULL
130 -- Iteration 7 --
132 Warning: end() expects parameter 1 to be array, double given in %s on line %d
133 NULL
135 -- Iteration 8 --
137 Warning: end() expects parameter 1 to be array, double given in %s on line %d
138 NULL
140 -- Iteration 9 --
142 Warning: end() expects parameter 1 to be array, double given in %s on line %d
143 NULL
145 -- Iteration 10 --
147 Warning: end() expects parameter 1 to be array, null given in %s on line %d
148 NULL
150 -- Iteration 11 --
152 Warning: end() expects parameter 1 to be array, null given in %s on line %d
153 NULL
155 -- Iteration 12 --
157 Warning: end() expects parameter 1 to be array, boolean given in %s on line %d
158 NULL
160 -- Iteration 13 --
162 Warning: end() expects parameter 1 to be array, boolean given in %s on line %d
163 NULL
165 -- Iteration 14 --
167 Warning: end() expects parameter 1 to be array, boolean given in %s on line %d
168 NULL
170 -- Iteration 15 --
172 Warning: end() expects parameter 1 to be array, boolean given in %s on line %d
173 NULL
175 -- Iteration 16 --
177 Warning: end() expects parameter 1 to be array, string given in %s on line %d
178 NULL
180 -- Iteration 17 --
182 Warning: end() expects parameter 1 to be array, string given in %s on line %d
183 NULL
185 -- Iteration 18 --
186 bool(false)
188 -- Iteration 19 --
190 Warning: end() expects parameter 1 to be array, string given in %s on line %d
191 NULL
193 -- Iteration 20 --
195 Warning: end() expects parameter 1 to be array, string given in %s on line %d
196 NULL
198 -- Iteration 21 --
200 Warning: end() expects parameter 1 to be array, string given in %s on line %d
201 NULL
203 -- Iteration 22 --
204 string(12) "hello, world"
206 -- Iteration 23 --
208 Warning: end() expects parameter 1 to be array, null given in %s on line %d
209 NULL
211 -- Iteration 24 --
213 Warning: end() expects parameter 1 to be array, null given in %s on line %d
214 NULL
216 -- Iteration 25 --
218 Warning: end() expects parameter 1 to be array, resource given in %s on line %d
219 NULL
220 ===DONE===