1--TEST--
2Test var_export() function with valid arrays
3--INI--
4serialize_precision=17
5--FILE--
6<?php
7/* Prototype  : mixed var_export(mixed var [, bool return])
8 * Description: Outputs or returns a string representation of a variable
9 * Source code: ext/standard/var.c
10 * Alias to functions:
11 */
12
13
14echo "*** Testing var_export() with valid arrays ***\n";
15// different valid  arrays
16$valid_arrays = array(
17           "array()" => array(),
18           "array(NULL)" => array(NULL),
19           "array(null)" => array(null),
20           "array(true)" => array(true),
21           "array(\"\")" => array(""),
22           "array('')" => array(''),
23           "array(array(), array())" => array(array(), array()),
24           "array(array(1, 2), array('a', 'b'))" => array(array(1, 2), array('a', 'b')),
25           "array(1 => 'One')" => array(1 => 'One'),
26           "array(\"test\" => \"is_array\")" => array("test" => "is_array"),
27           "array(0)" => array(0),
28           "array(-1)" => array(-1),
29           "array(10.5, 5.6)" => array(10.5, 5.6),
30           "array(\"string\", \"test\")" => array("string", "test"),
31           "array('string', 'test')" => array('string', 'test')
32);
33
34/* Loop to check for above arrays with var_export() */
35echo "\n*** Output for arrays ***\n";
36foreach($valid_arrays as $key => $arr) {
37	echo "\n--Iteration: $key --\n";
38	var_export( $arr );
39	echo "\n";
40	var_export( $arr, FALSE);
41	echo "\n";
42	var_dump( var_export( $arr, TRUE) );
43	echo "\n";
44}
45?>
46===DONE===
47--EXPECT--
48*** Testing var_export() with valid arrays ***
49
50*** Output for arrays ***
51
52--Iteration: array() --
53array (
54)
55array (
56)
57string(9) "array (
58)"
59
60
61--Iteration: array(NULL) --
62array (
63  0 => NULL,
64)
65array (
66  0 => NULL,
67)
68string(22) "array (
69  0 => NULL,
70)"
71
72
73--Iteration: array(null) --
74array (
75  0 => NULL,
76)
77array (
78  0 => NULL,
79)
80string(22) "array (
81  0 => NULL,
82)"
83
84
85--Iteration: array(true) --
86array (
87  0 => true,
88)
89array (
90  0 => true,
91)
92string(22) "array (
93  0 => true,
94)"
95
96
97--Iteration: array("") --
98array (
99  0 => '',
100)
101array (
102  0 => '',
103)
104string(20) "array (
105  0 => '',
106)"
107
108
109--Iteration: array('') --
110array (
111  0 => '',
112)
113array (
114  0 => '',
115)
116string(20) "array (
117  0 => '',
118)"
119
120
121--Iteration: array(array(), array()) --
122array (
123  0 =>
124  array (
125  ),
126  1 =>
127  array (
128  ),
129)
130array (
131  0 =>
132  array (
133  ),
134  1 =>
135  array (
136  ),
137)
138string(55) "array (
139  0 =>
140  array (
141  ),
142  1 =>
143  array (
144  ),
145)"
146
147
148--Iteration: array(array(1, 2), array('a', 'b')) --
149array (
150  0 =>
151  array (
152    0 => 1,
153    1 => 2,
154  ),
155  1 =>
156  array (
157    0 => 'a',
158    1 => 'b',
159  ),
160)
161array (
162  0 =>
163  array (
164    0 => 1,
165    1 => 2,
166  ),
167  1 =>
168  array (
169    0 => 'a',
170    1 => 'b',
171  ),
172)
173string(107) "array (
174  0 =>
175  array (
176    0 => 1,
177    1 => 2,
178  ),
179  1 =>
180  array (
181    0 => 'a',
182    1 => 'b',
183  ),
184)"
185
186
187--Iteration: array(1 => 'One') --
188array (
189  1 => 'One',
190)
191array (
192  1 => 'One',
193)
194string(23) "array (
195  1 => 'One',
196)"
197
198
199--Iteration: array("test" => "is_array") --
200array (
201  'test' => 'is_array',
202)
203array (
204  'test' => 'is_array',
205)
206string(33) "array (
207  'test' => 'is_array',
208)"
209
210
211--Iteration: array(0) --
212array (
213  0 => 0,
214)
215array (
216  0 => 0,
217)
218string(19) "array (
219  0 => 0,
220)"
221
222
223--Iteration: array(-1) --
224array (
225  0 => -1,
226)
227array (
228  0 => -1,
229)
230string(20) "array (
231  0 => -1,
232)"
233
234
235--Iteration: array(10.5, 5.6) --
236array (
237  0 => 10.5,
238  1 => 5.5999999999999996,
239)
240array (
241  0 => 10.5,
242  1 => 5.5999999999999996,
243)
244string(49) "array (
245  0 => 10.5,
246  1 => 5.5999999999999996,
247)"
248
249
250--Iteration: array("string", "test") --
251array (
252  0 => 'string',
253  1 => 'test',
254)
255array (
256  0 => 'string',
257  1 => 'test',
258)
259string(41) "array (
260  0 => 'string',
261  1 => 'test',
262)"
263
264
265--Iteration: array('string', 'test') --
266array (
267  0 => 'string',
268  1 => 'test',
269)
270array (
271  0 => 'string',
272  1 => 'test',
273)
274string(41) "array (
275  0 => 'string',
276  1 => 'test',
277)"
278
279===DONE===
280