Return to sizeof_variation4.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test sizeof() function : usage variations - all kinds of unset variables for 'var' argument 3: --FILE-- 4: <?php 5: /* Prototype : int sizeof($mixed var[, int $mode]) 6: * Description: Counts an elements in an array. If Standard PHP library is installed, 7: * it will return the properties of an object. 8: * Source code: ext/standard/basic_functions.c 9: * Alias to functions: count() 10: */ 11: 12: echo "*** Testing sizeof() : usage variations ***\n"; 13: 14: echo "--- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes ---\n"; 15: 16: // class declaration 17: class test 18: { 19: public $member1; 20: } 21: 22: // get an resource variable 23: $fp = fopen(__FILE__, "r"); 24: 25: // array containing different types of variables 26: $values = array ( 27: // int values 28: /* 1 */ 0, 29: 1, 30: // float values 31: /* 3 */ 10.5, 32: -10.5, 33: 12.34e3, 34: /* 6 */ 12.34E-3, 35: // string values 36: /* 7 */ "string", 37: 'string', 38: "", 39: /* 10 */ '', 40: // NULL values 41: /* 11 */ NULL, 42: null, 43: // Boolean Values 44: /* 12 */ TRUE, 45: true, 46: false, 47: /* 16 */ FALSE, 48: // array values 49: /* 17 */ array(), 50: array(1, 2, 3,4 , array(5, 6)), 51: // object variable 52: /* 19 */ new test(), 53: // resource variable 54: /* 20 */ $fp 55: ); 56: 57: // loop through the each element of the $values array for 'var' arugment 58: // and check the functionality of sizeof() 59: $counter = 1; 60: foreach($values as $value) 61: { 62: echo "-- Iteration $counter --\n"; 63: 64: // unset the variable 65: unset($value); 66: 67: // now check the size of unset variable when different modes are given 68: echo "Default Mode: "; 69: var_dump( sizeof($value) ); 70: echo "\n"; 71: 72: echo "COUNT_NORMAL Mode: "; 73: var_dump( sizeof($value, COUNT_NORMAL) ); 74: echo "\n"; 75: 76: echo "COUNT_RECURSIVE Mode: "; 77: var_dump( sizeof($value, COUNT_RECURSIVE) ); 78: echo "\n"; 79: 80: $counter++; 81: } 82: 83: fclose($fp); 84: 85: echo "Done"; 86: ?> 87: --EXPECTF-- 88: *** Testing sizeof() : usage variations *** 89: --- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes --- 90: -- Iteration 1 -- 91: Default Mode: 92: Notice: Undefined variable: value in %s on line %d 93: int(0) 94: 95: COUNT_NORMAL Mode: 96: Notice: Undefined variable: value in %s on line %d 97: int(0) 98: 99: COUNT_RECURSIVE Mode: 100: Notice: Undefined variable: value in %s on line %d 101: int(0) 102: 103: -- Iteration 2 -- 104: Default Mode: 105: Notice: Undefined variable: value in %s on line %d 106: int(0) 107: 108: COUNT_NORMAL Mode: 109: Notice: Undefined variable: value in %s on line %d 110: int(0) 111: 112: COUNT_RECURSIVE Mode: 113: Notice: Undefined variable: value in %s on line %d 114: int(0) 115: 116: -- Iteration 3 -- 117: Default Mode: 118: Notice: Undefined variable: value in %s on line %d 119: int(0) 120: 121: COUNT_NORMAL Mode: 122: Notice: Undefined variable: value in %s on line %d 123: int(0) 124: 125: COUNT_RECURSIVE Mode: 126: Notice: Undefined variable: value in %s on line %d 127: int(0) 128: 129: -- Iteration 4 -- 130: Default Mode: 131: Notice: Undefined variable: value in %s on line %d 132: int(0) 133: 134: COUNT_NORMAL Mode: 135: Notice: Undefined variable: value in %s on line %d 136: int(0) 137: 138: COUNT_RECURSIVE Mode: 139: Notice: Undefined variable: value in %s on line %d 140: int(0) 141: 142: -- Iteration 5 -- 143: Default Mode: 144: Notice: Undefined variable: value in %s on line %d 145: int(0) 146: 147: COUNT_NORMAL Mode: 148: Notice: Undefined variable: value in %s on line %d 149: int(0) 150: 151: COUNT_RECURSIVE Mode: 152: Notice: Undefined variable: value in %s on line %d 153: int(0) 154: 155: -- Iteration 6 -- 156: Default Mode: 157: Notice: Undefined variable: value in %s on line %d 158: int(0) 159: 160: COUNT_NORMAL Mode: 161: Notice: Undefined variable: value in %s on line %d 162: int(0) 163: 164: COUNT_RECURSIVE Mode: 165: Notice: Undefined variable: value in %s on line %d 166: int(0) 167: 168: -- Iteration 7 -- 169: Default Mode: 170: Notice: Undefined variable: value in %s on line %d 171: int(0) 172: 173: COUNT_NORMAL Mode: 174: Notice: Undefined variable: value in %s on line %d 175: int(0) 176: 177: COUNT_RECURSIVE Mode: 178: Notice: Undefined variable: value in %s on line %d 179: int(0) 180: 181: -- Iteration 8 -- 182: Default Mode: 183: Notice: Undefined variable: value in %s on line %d 184: int(0) 185: 186: COUNT_NORMAL Mode: 187: Notice: Undefined variable: value in %s on line %d 188: int(0) 189: 190: COUNT_RECURSIVE Mode: 191: Notice: Undefined variable: value in %s on line %d 192: int(0) 193: 194: -- Iteration 9 -- 195: Default Mode: 196: Notice: Undefined variable: value in %s on line %d 197: int(0) 198: 199: COUNT_NORMAL Mode: 200: Notice: Undefined variable: value in %s on line %d 201: int(0) 202: 203: COUNT_RECURSIVE Mode: 204: Notice: Undefined variable: value in %s on line %d 205: int(0) 206: 207: -- Iteration 10 -- 208: Default Mode: 209: Notice: Undefined variable: value in %s on line %d 210: int(0) 211: 212: COUNT_NORMAL Mode: 213: Notice: Undefined variable: value in %s on line %d 214: int(0) 215: 216: COUNT_RECURSIVE Mode: 217: Notice: Undefined variable: value in %s on line %d 218: int(0) 219: 220: -- Iteration 11 -- 221: Default Mode: 222: Notice: Undefined variable: value in %s on line %d 223: int(0) 224: 225: COUNT_NORMAL Mode: 226: Notice: Undefined variable: value in %s on line %d 227: int(0) 228: 229: COUNT_RECURSIVE Mode: 230: Notice: Undefined variable: value in %s on line %d 231: int(0) 232: 233: -- Iteration 12 -- 234: Default Mode: 235: Notice: Undefined variable: value in %s on line %d 236: int(0) 237: 238: COUNT_NORMAL Mode: 239: Notice: Undefined variable: value in %s on line %d 240: int(0) 241: 242: COUNT_RECURSIVE Mode: 243: Notice: Undefined variable: value in %s on line %d 244: int(0) 245: 246: -- Iteration 13 -- 247: Default Mode: 248: Notice: Undefined variable: value in %s on line %d 249: int(0) 250: 251: COUNT_NORMAL Mode: 252: Notice: Undefined variable: value in %s on line %d 253: int(0) 254: 255: COUNT_RECURSIVE Mode: 256: Notice: Undefined variable: value in %s on line %d 257: int(0) 258: 259: -- Iteration 14 -- 260: Default Mode: 261: Notice: Undefined variable: value in %s on line %d 262: int(0) 263: 264: COUNT_NORMAL Mode: 265: Notice: Undefined variable: value in %s on line %d 266: int(0) 267: 268: COUNT_RECURSIVE Mode: 269: Notice: Undefined variable: value in %s on line %d 270: int(0) 271: 272: -- Iteration 15 -- 273: Default Mode: 274: Notice: Undefined variable: value in %s on line %d 275: int(0) 276: 277: COUNT_NORMAL Mode: 278: Notice: Undefined variable: value in %s on line %d 279: int(0) 280: 281: COUNT_RECURSIVE Mode: 282: Notice: Undefined variable: value in %s on line %d 283: int(0) 284: 285: -- Iteration 16 -- 286: Default Mode: 287: Notice: Undefined variable: value in %s on line %d 288: int(0) 289: 290: COUNT_NORMAL Mode: 291: Notice: Undefined variable: value in %s on line %d 292: int(0) 293: 294: COUNT_RECURSIVE Mode: 295: Notice: Undefined variable: value in %s on line %d 296: int(0) 297: 298: -- Iteration 17 -- 299: Default Mode: 300: Notice: Undefined variable: value in %s on line %d 301: int(0) 302: 303: COUNT_NORMAL Mode: 304: Notice: Undefined variable: value in %s on line %d 305: int(0) 306: 307: COUNT_RECURSIVE Mode: 308: Notice: Undefined variable: value in %s on line %d 309: int(0) 310: 311: -- Iteration 18 -- 312: Default Mode: 313: Notice: Undefined variable: value in %s on line %d 314: int(0) 315: 316: COUNT_NORMAL Mode: 317: Notice: Undefined variable: value in %s on line %d 318: int(0) 319: 320: COUNT_RECURSIVE Mode: 321: Notice: Undefined variable: value in %s on line %d 322: int(0) 323: 324: -- Iteration 19 -- 325: Default Mode: 326: Notice: Undefined variable: value in %s on line %d 327: int(0) 328: 329: COUNT_NORMAL Mode: 330: Notice: Undefined variable: value in %s on line %d 331: int(0) 332: 333: COUNT_RECURSIVE Mode: 334: Notice: Undefined variable: value in %s on line %d 335: int(0) 336: 337: -- Iteration 20 -- 338: Default Mode: 339: Notice: Undefined variable: value in %s on line %d 340: int(0) 341: 342: COUNT_NORMAL Mode: 343: Notice: Undefined variable: value in %s on line %d 344: int(0) 345: 346: COUNT_RECURSIVE Mode: 347: Notice: Undefined variable: value in %s on line %d 348: int(0) 349: 350: Done