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