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 9--FILE-- 10<?php 11/* Prototype: void debug_zval_dump ( mixed $variable ); 12 Description: Dumps a string representation of an internal zend value 13 to output. 14*/ 15 16/* creating file resource */ 17$file_handle = fopen(__FILE__, "r"); 18 19echo "*** Testing debug_zval_dump() on scalar and non-scalar variables ***\n"; 20$values = array ( 21 /* integers */ 22 0, // zero as argument 23 000000123, //octal value of 83 24 123000000, 25 -00000123, //octal value of 83 26 -12300000, 27 0xffffff, //hexadecimal value 28 123456789, 29 1, 30 -1, 31 32 /* floats */ 33 -0.0, 34 +0.0, 35 1.234, 36 -1.234, 37 -2.000000, 38 2.0000000, 39 -4.0001e+5, 40 4.0001E+5, 41 6.99999989, 42 -.5, 43 .567, 44 -.6700000e-3, 45 -.6700000E+3, 46 1E-5, 47 -1e+5, 48 1e+5, 49 1E-5, 50 51 /* strings */ 52 "", 53 '', 54 " ", 55 ' ', 56 "0", 57 "\0", 58 '\0', 59 "\t", 60 '\t', 61 "PHP", 62 'PHP', 63 "1234\t\n5678\n\t9100\rabcda\x0000cdeh\0stuv", // strings with escape chars 64 65 /* boolean */ 66 TRUE, 67 FALSE, 68 true, 69 false, 70 71 /* arrays */ 72 array(), 73 array(NULL), 74 array(true), 75 array(""), 76 array(''), 77 array(array(1, 2), array('a', 'b')), 78 array("test" => "is_array", 1 => 'One'), 79 array(0), 80 array(-1), 81 array(10.5, 5.6), 82 array("string", "test"), 83 array('string', 'test'), 84 85 /* resources */ 86 $file_handle 87); 88/* loop to display the variables and its reference count using 89 debug_zval_dump() */ 90$counter = 1; 91foreach( $values as $value ) { 92 echo "-- Iteration $counter --\n"; 93 debug_zval_dump( $value ); 94 $counter++; 95} 96 97/* closing resource handle */ 98fclose($file_handle); 99 100echo "Done\n"; 101?> 102--EXPECTF-- 103*** Testing debug_zval_dump() on scalar and non-scalar variables *** 104-- Iteration 1 -- 105long(0) refcount(3) 106-- Iteration 2 -- 107long(83) refcount(3) 108-- Iteration 3 -- 109long(123000000) refcount(3) 110-- Iteration 4 -- 111long(-83) refcount(3) 112-- Iteration 5 -- 113long(-12300000) refcount(3) 114-- Iteration 6 -- 115long(16777215) refcount(3) 116-- Iteration 7 -- 117long(123456789) refcount(3) 118-- Iteration 8 -- 119long(1) refcount(3) 120-- Iteration 9 -- 121long(-1) refcount(3) 122-- Iteration 10 -- 123double(0) refcount(3) 124-- Iteration 11 -- 125double(0) refcount(3) 126-- Iteration 12 -- 127double(1.234) refcount(3) 128-- Iteration 13 -- 129double(-1.234) refcount(3) 130-- Iteration 14 -- 131double(-2) refcount(3) 132-- Iteration 15 -- 133double(2) refcount(3) 134-- Iteration 16 -- 135double(-400010) refcount(3) 136-- Iteration 17 -- 137double(400010) refcount(3) 138-- Iteration 18 -- 139double(6.99999989) refcount(3) 140-- Iteration 19 -- 141double(-0.5) refcount(3) 142-- Iteration 20 -- 143double(0.567) refcount(3) 144-- Iteration 21 -- 145double(-0.00067) refcount(3) 146-- Iteration 22 -- 147double(-670) refcount(3) 148-- Iteration 23 -- 149double(1.0E-5) refcount(3) 150-- Iteration 24 -- 151double(-100000) refcount(3) 152-- Iteration 25 -- 153double(100000) refcount(3) 154-- Iteration 26 -- 155double(1.0E-5) refcount(3) 156-- Iteration 27 -- 157string(0) "" refcount(3) 158-- Iteration 28 -- 159string(0) "" refcount(3) 160-- Iteration 29 -- 161string(1) " " refcount(3) 162-- Iteration 30 -- 163string(1) " " refcount(3) 164-- Iteration 31 -- 165string(1) "0" refcount(3) 166-- Iteration 32 -- 167string(1) "" refcount(3) 168-- Iteration 33 -- 169string(2) "\0" refcount(3) 170-- Iteration 34 -- 171string(1) " " refcount(3) 172-- Iteration 35 -- 173string(2) "\t" refcount(3) 174-- Iteration 36 -- 175string(3) "PHP" refcount(3) 176-- Iteration 37 -- 177string(3) "PHP" refcount(3) 178-- Iteration 38 -- 179string(34) "1234 1805678 181 9100 181abcda00cdehstuv" refcount(3) 182-- Iteration 39 -- 183bool(true) refcount(3) 184-- Iteration 40 -- 185bool(false) refcount(3) 186-- Iteration 41 -- 187bool(true) refcount(3) 188-- Iteration 42 -- 189bool(false) refcount(3) 190-- Iteration 43 -- 191array(0) refcount(3){ 192} 193-- Iteration 44 -- 194array(1) refcount(3){ 195 [0]=> 196 NULL refcount(1) 197} 198-- Iteration 45 -- 199array(1) refcount(3){ 200 [0]=> 201 bool(true) refcount(1) 202} 203-- Iteration 46 -- 204array(1) refcount(3){ 205 [0]=> 206 string(0) "" refcount(1) 207} 208-- Iteration 47 -- 209array(1) refcount(3){ 210 [0]=> 211 string(0) "" refcount(1) 212} 213-- Iteration 48 -- 214array(2) refcount(3){ 215 [0]=> 216 array(2) refcount(1){ 217 [0]=> 218 long(1) refcount(1) 219 [1]=> 220 long(2) refcount(1) 221 } 222 [1]=> 223 array(2) refcount(1){ 224 [0]=> 225 string(1) "a" refcount(1) 226 [1]=> 227 string(1) "b" refcount(1) 228 } 229} 230-- Iteration 49 -- 231array(2) refcount(3){ 232 ["test"]=> 233 string(8) "is_array" refcount(1) 234 [1]=> 235 string(3) "One" refcount(1) 236} 237-- Iteration 50 -- 238array(1) refcount(3){ 239 [0]=> 240 long(0) refcount(1) 241} 242-- Iteration 51 -- 243array(1) refcount(3){ 244 [0]=> 245 long(-1) refcount(1) 246} 247-- Iteration 52 -- 248array(2) refcount(3){ 249 [0]=> 250 double(10.5) refcount(1) 251 [1]=> 252 double(5.6) refcount(1) 253} 254-- Iteration 53 -- 255array(2) refcount(3){ 256 [0]=> 257 string(6) "string" refcount(1) 258 [1]=> 259 string(4) "test" refcount(1) 260} 261-- Iteration 54 -- 262array(2) refcount(3){ 263 [0]=> 264 string(6) "string" refcount(1) 265 [1]=> 266 string(4) "test" refcount(1) 267} 268-- Iteration 55 -- 269resource(%d) of type (stream) refcount(4) 270Done 271