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