Annotation of embedaddon/php/ext/standard/tests/general_functions/var_export_basic5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
12: echo "*** 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() */
33: echo "\n*** Output for arrays ***\n";
34: foreach($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() --
51: array (
52: )
53: array (
54: )
55: string(9) "array (
56: )"
57:
58:
59: --Iteration: array(NULL) --
60: array (
61: 0 => NULL,
62: )
63: array (
64: 0 => NULL,
65: )
66: string(22) "array (
67: 0 => NULL,
68: )"
69:
70:
71: --Iteration: array(null) --
72: array (
73: 0 => NULL,
74: )
75: array (
76: 0 => NULL,
77: )
78: string(22) "array (
79: 0 => NULL,
80: )"
81:
82:
83: --Iteration: array(true) --
84: array (
85: 0 => true,
86: )
87: array (
88: 0 => true,
89: )
90: string(22) "array (
91: 0 => true,
92: )"
93:
94:
95: --Iteration: array("") --
96: array (
97: 0 => '',
98: )
99: array (
100: 0 => '',
101: )
102: string(20) "array (
103: 0 => '',
104: )"
105:
106:
107: --Iteration: array('') --
108: array (
109: 0 => '',
110: )
111: array (
112: 0 => '',
113: )
114: string(20) "array (
115: 0 => '',
116: )"
117:
118:
119: --Iteration: array(array(), array()) --
120: array (
121: 0 =>
122: array (
123: ),
124: 1 =>
125: array (
126: ),
127: )
128: array (
129: 0 =>
130: array (
131: ),
132: 1 =>
133: array (
134: ),
135: )
136: string(55) "array (
137: 0 =>
138: array (
139: ),
140: 1 =>
141: array (
142: ),
143: )"
144:
145:
146: --Iteration: array(array(1, 2), array('a', 'b')) --
147: array (
148: 0 =>
149: array (
150: 0 => 1,
151: 1 => 2,
152: ),
153: 1 =>
154: array (
155: 0 => 'a',
156: 1 => 'b',
157: ),
158: )
159: array (
160: 0 =>
161: array (
162: 0 => 1,
163: 1 => 2,
164: ),
165: 1 =>
166: array (
167: 0 => 'a',
168: 1 => 'b',
169: ),
170: )
171: string(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') --
186: array (
187: 1 => 'One',
188: )
189: array (
190: 1 => 'One',
191: )
192: string(23) "array (
193: 1 => 'One',
194: )"
195:
196:
197: --Iteration: array("test" => "is_array") --
198: array (
199: 'test' => 'is_array',
200: )
201: array (
202: 'test' => 'is_array',
203: )
204: string(33) "array (
205: 'test' => 'is_array',
206: )"
207:
208:
209: --Iteration: array(0) --
210: array (
211: 0 => 0,
212: )
213: array (
214: 0 => 0,
215: )
216: string(19) "array (
217: 0 => 0,
218: )"
219:
220:
221: --Iteration: array(-1) --
222: array (
223: 0 => -1,
224: )
225: array (
226: 0 => -1,
227: )
228: string(20) "array (
229: 0 => -1,
230: )"
231:
232:
233: --Iteration: array(10.5, 5.6) --
234: array (
235: 0 => 10.5,
236: 1 => 5.6,
237: )
238: array (
239: 0 => 10.5,
240: 1 => 5.6,
241: )
242: string(34) "array (
243: 0 => 10.5,
244: 1 => 5.6,
245: )"
246:
247:
248: --Iteration: array("string", "test") --
249: array (
250: 0 => 'string',
251: 1 => 'test',
252: )
253: array (
254: 0 => 'string',
255: 1 => 'test',
256: )
257: string(41) "array (
258: 0 => 'string',
259: 1 => 'test',
260: )"
261:
262:
263: --Iteration: array('string', 'test') --
264: array (
265: 0 => 'string',
266: 1 => 'test',
267: )
268: array (
269: 0 => 'string',
270: 1 => 'test',
271: )
272: string(41) "array (
273: 0 => 'string',
274: 1 => 'test',
275: )"
276:
277: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>