Annotation of embedaddon/php/ext/standard/tests/array/sizeof_variation1.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test sizeof() function : usage variations - for all scalar types and resource variable
                      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 scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode ---\n";
                     15: // get a resource variable
                     16: $fp = fopen(__FILE__, "r");
                     17: 
                     18: // array containing all scalar types 
                     19: $values = array (
                     20:            // int values
                     21:   /* 1  */  0,
                     22:             1,
                     23: 
                     24:             // float values
                     25:   /* 3  */   10.5,
                     26:             -10.5,
                     27:             12.3456789000e10,
                     28:             12.3456789000E-10,
                     29:   /* 7  */  .5,
                     30:             
                     31:             // NULL values
                     32:   /* 8  */  NULL,
                     33:             null,
                     34: 
                     35:             // boolean values 
                     36:   /* 10 */  TRUE,
                     37:             FALSE,
                     38:             true,
                     39:   /* 13 */  false,
                     40: 
                     41:             // string data 
                     42:   /* 14 */  "",
                     43:             '',  
                     44:             "string",
                     45:   /* 17 */  'string',
                     46: 
                     47:             // undefined variable 
                     48:             @$undefined_var,
                     49: 
                     50:             // resource variable 
                     51:   /* 19 */  $fp
                     52: );
                     53: 
                     54: // loop through the each value of the array for 'var' argument and check the behaviour of sizeof()
                     55: $counter = 1;
                     56: for($i = 0; $i < count($values); $i++)
                     57: {
                     58:   echo "-- Iteration $counter --\n";
                     59:  
                     60:   $var = $values[$i]; 
                     61: 
                     62:   echo "Default Mode: ";
                     63:   var_dump( sizeof($var) );
                     64:   echo "\n";
                     65: 
                     66:   echo "COUNT_NORMAL Mode: ";
                     67:   var_dump( sizeof($var, COUNT_NORMAL) );
                     68:   echo "\n";
                     69:      
                     70:   echo "COUNT_RECURSIVE Mode: ";
                     71:   var_dump( sizeof($var, COUNT_RECURSIVE) );
                     72:   echo "\n";
                     73:   
                     74:   $counter++;
                     75: }
                     76:       
                     77: echo "Done";
                     78: ?>
                     79: --EXPECTF--
                     80: *** Testing sizeof() : usage variations ***
                     81: --- Testing sizeof() for all scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode ---
                     82: -- Iteration 1 --
                     83: Default Mode: int(1)
                     84: 
                     85: COUNT_NORMAL Mode: int(1)
                     86: 
                     87: COUNT_RECURSIVE Mode: int(1)
                     88: 
                     89: -- Iteration 2 --
                     90: Default Mode: int(1)
                     91: 
                     92: COUNT_NORMAL Mode: int(1)
                     93: 
                     94: COUNT_RECURSIVE Mode: int(1)
                     95: 
                     96: -- Iteration 3 --
                     97: Default Mode: int(1)
                     98: 
                     99: COUNT_NORMAL Mode: int(1)
                    100: 
                    101: COUNT_RECURSIVE Mode: int(1)
                    102: 
                    103: -- Iteration 4 --
                    104: Default Mode: int(1)
                    105: 
                    106: COUNT_NORMAL Mode: int(1)
                    107: 
                    108: COUNT_RECURSIVE Mode: int(1)
                    109: 
                    110: -- Iteration 5 --
                    111: Default Mode: int(1)
                    112: 
                    113: COUNT_NORMAL Mode: int(1)
                    114: 
                    115: COUNT_RECURSIVE Mode: int(1)
                    116: 
                    117: -- Iteration 6 --
                    118: Default Mode: int(1)
                    119: 
                    120: COUNT_NORMAL Mode: int(1)
                    121: 
                    122: COUNT_RECURSIVE Mode: int(1)
                    123: 
                    124: -- Iteration 7 --
                    125: Default Mode: int(1)
                    126: 
                    127: COUNT_NORMAL Mode: int(1)
                    128: 
                    129: COUNT_RECURSIVE Mode: int(1)
                    130: 
                    131: -- Iteration 8 --
                    132: Default Mode: int(0)
                    133: 
                    134: COUNT_NORMAL Mode: int(0)
                    135: 
                    136: COUNT_RECURSIVE Mode: int(0)
                    137: 
                    138: -- Iteration 9 --
                    139: Default Mode: int(0)
                    140: 
                    141: COUNT_NORMAL Mode: int(0)
                    142: 
                    143: COUNT_RECURSIVE Mode: int(0)
                    144: 
                    145: -- Iteration 10 --
                    146: Default Mode: int(1)
                    147: 
                    148: COUNT_NORMAL Mode: int(1)
                    149: 
                    150: COUNT_RECURSIVE Mode: int(1)
                    151: 
                    152: -- Iteration 11 --
                    153: Default Mode: int(1)
                    154: 
                    155: COUNT_NORMAL Mode: int(1)
                    156: 
                    157: COUNT_RECURSIVE Mode: int(1)
                    158: 
                    159: -- Iteration 12 --
                    160: Default Mode: int(1)
                    161: 
                    162: COUNT_NORMAL Mode: int(1)
                    163: 
                    164: COUNT_RECURSIVE Mode: int(1)
                    165: 
                    166: -- Iteration 13 --
                    167: Default Mode: int(1)
                    168: 
                    169: COUNT_NORMAL Mode: int(1)
                    170: 
                    171: COUNT_RECURSIVE Mode: int(1)
                    172: 
                    173: -- Iteration 14 --
                    174: Default Mode: int(1)
                    175: 
                    176: COUNT_NORMAL Mode: int(1)
                    177: 
                    178: COUNT_RECURSIVE Mode: int(1)
                    179: 
                    180: -- Iteration 15 --
                    181: Default Mode: int(1)
                    182: 
                    183: COUNT_NORMAL Mode: int(1)
                    184: 
                    185: COUNT_RECURSIVE Mode: int(1)
                    186: 
                    187: -- Iteration 16 --
                    188: Default Mode: int(1)
                    189: 
                    190: COUNT_NORMAL Mode: int(1)
                    191: 
                    192: COUNT_RECURSIVE Mode: int(1)
                    193: 
                    194: -- Iteration 17 --
                    195: Default Mode: int(1)
                    196: 
                    197: COUNT_NORMAL Mode: int(1)
                    198: 
                    199: COUNT_RECURSIVE Mode: int(1)
                    200: 
                    201: -- Iteration 18 --
                    202: Default Mode: int(0)
                    203: 
                    204: COUNT_NORMAL Mode: int(0)
                    205: 
                    206: COUNT_RECURSIVE Mode: int(0)
                    207: 
                    208: -- Iteration 19 --
                    209: Default Mode: int(1)
                    210: 
                    211: COUNT_NORMAL Mode: int(1)
                    212: 
                    213: COUNT_RECURSIVE Mode: int(1)
                    214: 
                    215: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>