1--TEST--
2Test debug_zval_dump() function : basic operations
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
6?>
7--INI--
8precision=14
9allow_call_time_pass_reference=1
10--FILE--
11<?php
12/* Prototype: void debug_zval_dump ( mixed $variable );
13   Description: Dumps a string representation of an internal zend value
14                to output.
15*/
16
17/* creating file resource */
18$file_handle = fopen(__FILE__, "r");
19
20echo "*** Testing debug_zval_dump() on scalar and non-scalar variables ***\n";
21$values = array (
22  /* integers */
23  0,  // zero as argument
24  000000123,  //octal value of 83
25  123000000,
26  -00000123,  //octal value of 83
27  -12300000,
28  0xffffff,  //hexadecimal value
29  123456789,
30  1,
31  -1,
32
33  /* floats */
34  -0.0,
35  +0.0,
36  1.234,
37  -1.234,
38  -2.000000,
39  2.0000000,
40  -4.0001e+5,
41  4.0001E+5,
42  6.99999989,
43  -.5,
44  .567,
45  -.6700000e-3,
46  -.6700000E+3,
47  1E-5,
48  -1e+5,
49  1e+5,
50  1E-5,
51
52  /* strings */
53  "",
54  '',
55  " ",
56  ' ',
57  "0",
58  "\0",
59  '\0',
60  "\t",
61  '\t',
62  "PHP",
63  'PHP',
64  "1234\t\n5678\n\t9100\rabcda\x0000cdeh\0stuv",  // strings with escape chars
65
66  /* boolean */
67  TRUE,
68  FALSE,
69  true,
70  false,
71
72  /* arrays */
73  array(),
74  array(NULL),
75  array(true),
76  array(""),
77  array(''),
78  array(array(1, 2), array('a', 'b')),
79  array("test" => "is_array", 1 => 'One'),
80  array(0),
81  array(-1),
82  array(10.5, 5.6),
83  array("string", "test"),
84  array('string', 'test'),
85
86  /* resources */
87  $file_handle
88);
89/* loop to display the variables and its reference count using
90    debug_zval_dump() */
91$counter = 1;
92foreach( $values as $value ) {
93  echo "-- Iteration $counter --\n";
94  debug_zval_dump( $value );
95  debug_zval_dump( &$value );
96  $counter++;
97}
98
99/* closing resource handle */
100fclose($file_handle);
101
102echo "Done\n";
103?>
104--EXPECTF--
105*** Testing debug_zval_dump() on scalar and non-scalar variables ***
106-- Iteration 1 --
107long(0) refcount(3)
108&long(0) refcount(2)
109-- Iteration 2 --
110long(83) refcount(3)
111&long(83) refcount(2)
112-- Iteration 3 --
113long(123000000) refcount(3)
114&long(123000000) refcount(2)
115-- Iteration 4 --
116long(-83) refcount(3)
117&long(-83) refcount(2)
118-- Iteration 5 --
119long(-12300000) refcount(3)
120&long(-12300000) refcount(2)
121-- Iteration 6 --
122long(16777215) refcount(3)
123&long(16777215) refcount(2)
124-- Iteration 7 --
125long(123456789) refcount(3)
126&long(123456789) refcount(2)
127-- Iteration 8 --
128long(1) refcount(3)
129&long(1) refcount(2)
130-- Iteration 9 --
131long(-1) refcount(3)
132&long(-1) refcount(2)
133-- Iteration 10 --
134double(0) refcount(3)
135&double(0) refcount(2)
136-- Iteration 11 --
137double(0) refcount(3)
138&double(0) refcount(2)
139-- Iteration 12 --
140double(1.234) refcount(3)
141&double(1.234) refcount(2)
142-- Iteration 13 --
143double(-1.234) refcount(3)
144&double(-1.234) refcount(2)
145-- Iteration 14 --
146double(-2) refcount(3)
147&double(-2) refcount(2)
148-- Iteration 15 --
149double(2) refcount(3)
150&double(2) refcount(2)
151-- Iteration 16 --
152double(-400010) refcount(3)
153&double(-400010) refcount(2)
154-- Iteration 17 --
155double(400010) refcount(3)
156&double(400010) refcount(2)
157-- Iteration 18 --
158double(6.99999989) refcount(3)
159&double(6.99999989) refcount(2)
160-- Iteration 19 --
161double(-0.5) refcount(3)
162&double(-0.5) refcount(2)
163-- Iteration 20 --
164double(0.567) refcount(3)
165&double(0.567) refcount(2)
166-- Iteration 21 --
167double(-0.00067) refcount(3)
168&double(-0.00067) refcount(2)
169-- Iteration 22 --
170double(-670) refcount(3)
171&double(-670) refcount(2)
172-- Iteration 23 --
173double(1.0E-5) refcount(3)
174&double(1.0E-5) refcount(2)
175-- Iteration 24 --
176double(-100000) refcount(3)
177&double(-100000) refcount(2)
178-- Iteration 25 --
179double(100000) refcount(3)
180&double(100000) refcount(2)
181-- Iteration 26 --
182double(1.0E-5) refcount(3)
183&double(1.0E-5) refcount(2)
184-- Iteration 27 --
185string(0) "" refcount(3)
186&string(0) "" refcount(2)
187-- Iteration 28 --
188string(0) "" refcount(3)
189&string(0) "" refcount(2)
190-- Iteration 29 --
191string(1) " " refcount(3)
192&string(1) " " refcount(2)
193-- Iteration 30 --
194string(1) " " refcount(3)
195&string(1) " " refcount(2)
196-- Iteration 31 --
197string(1) "0" refcount(3)
198&string(1) "0" refcount(2)
199-- Iteration 32 --
200string(1) "�" refcount(3)
201&string(1) "�" refcount(2)
202-- Iteration 33 --
203string(2) "\0" refcount(3)
204&string(2) "\0" refcount(2)
205-- Iteration 34 --
206string(1) "	" refcount(3)
207&string(1) "	" refcount(2)
208-- Iteration 35 --
209string(2) "\t" refcount(3)
210&string(2) "\t" refcount(2)
211-- Iteration 36 --
212string(3) "PHP" refcount(3)
213&string(3) "PHP" refcount(2)
214-- Iteration 37 --
215string(3) "PHP" refcount(3)
216&string(3) "PHP" refcount(2)
217-- Iteration 38 --
218string(34) "1234
2195678
220	9100
220abcda�00cdeh�stuv" refcount(3)
221&string(34) "1234
2225678
223	9100
223abcda�00cdeh�stuv" refcount(2)
224-- Iteration 39 --
225bool(true) refcount(3)
226&bool(true) refcount(2)
227-- Iteration 40 --
228bool(false) refcount(3)
229&bool(false) refcount(2)
230-- Iteration 41 --
231bool(true) refcount(3)
232&bool(true) refcount(2)
233-- Iteration 42 --
234bool(false) refcount(3)
235&bool(false) refcount(2)
236-- Iteration 43 --
237array(0) refcount(3){
238}
239&array(0) refcount(2){
240}
241-- Iteration 44 --
242array(1) refcount(3){
243  [0]=>
244  NULL refcount(1)
245}
246&array(1) refcount(2){
247  [0]=>
248  NULL refcount(2)
249}
250-- Iteration 45 --
251array(1) refcount(3){
252  [0]=>
253  bool(true) refcount(1)
254}
255&array(1) refcount(2){
256  [0]=>
257  bool(true) refcount(2)
258}
259-- Iteration 46 --
260array(1) refcount(3){
261  [0]=>
262  string(0) "" refcount(1)
263}
264&array(1) refcount(2){
265  [0]=>
266  string(0) "" refcount(2)
267}
268-- Iteration 47 --
269array(1) refcount(3){
270  [0]=>
271  string(0) "" refcount(1)
272}
273&array(1) refcount(2){
274  [0]=>
275  string(0) "" refcount(2)
276}
277-- Iteration 48 --
278array(2) refcount(3){
279  [0]=>
280  array(2) refcount(1){
281    [0]=>
282    long(1) refcount(1)
283    [1]=>
284    long(2) refcount(1)
285  }
286  [1]=>
287  array(2) refcount(1){
288    [0]=>
289    string(1) "a" refcount(1)
290    [1]=>
291    string(1) "b" refcount(1)
292  }
293}
294&array(2) refcount(2){
295  [0]=>
296  array(2) refcount(2){
297    [0]=>
298    long(1) refcount(1)
299    [1]=>
300    long(2) refcount(1)
301  }
302  [1]=>
303  array(2) refcount(2){
304    [0]=>
305    string(1) "a" refcount(1)
306    [1]=>
307    string(1) "b" refcount(1)
308  }
309}
310-- Iteration 49 --
311array(2) refcount(3){
312  ["test"]=>
313  string(8) "is_array" refcount(1)
314  [1]=>
315  string(3) "One" refcount(1)
316}
317&array(2) refcount(2){
318  ["test"]=>
319  string(8) "is_array" refcount(2)
320  [1]=>
321  string(3) "One" refcount(2)
322}
323-- Iteration 50 --
324array(1) refcount(3){
325  [0]=>
326  long(0) refcount(1)
327}
328&array(1) refcount(2){
329  [0]=>
330  long(0) refcount(2)
331}
332-- Iteration 51 --
333array(1) refcount(3){
334  [0]=>
335  long(-1) refcount(1)
336}
337&array(1) refcount(2){
338  [0]=>
339  long(-1) refcount(2)
340}
341-- Iteration 52 --
342array(2) refcount(3){
343  [0]=>
344  double(10.5) refcount(1)
345  [1]=>
346  double(5.6) refcount(1)
347}
348&array(2) refcount(2){
349  [0]=>
350  double(10.5) refcount(2)
351  [1]=>
352  double(5.6) refcount(2)
353}
354-- Iteration 53 --
355array(2) refcount(3){
356  [0]=>
357  string(6) "string" refcount(1)
358  [1]=>
359  string(4) "test" refcount(1)
360}
361&array(2) refcount(2){
362  [0]=>
363  string(6) "string" refcount(2)
364  [1]=>
365  string(4) "test" refcount(2)
366}
367-- Iteration 54 --
368array(2) refcount(3){
369  [0]=>
370  string(6) "string" refcount(1)
371  [1]=>
372  string(4) "test" refcount(1)
373}
374&array(2) refcount(2){
375  [0]=>
376  string(6) "string" refcount(2)
377  [1]=>
378  string(4) "test" refcount(2)
379}
380-- Iteration 55 --
381resource(%d) of type (stream) refcount(4)
382&resource(%d) of type (stream) refcount(2)
383Done
384