cvs: php-src(PHP_5_2) /ext/standard/tests/array sizeof_basic1.phpt sizeof_basic2.phpt sizeof_error.phpt sizeof_object1.phpt sizeof_object2.phpt
sizeof_variation1.phpt sizeof_variation2.phpt sizeof_variation3.phpt sizeof_variation4.phpt sizeof_variation5.phpt

From: Date: Fri, 16 Nov 2007 17:55:55 +0000
Subject: cvs: php-src(PHP_5_2) /ext/standard/tests/array sizeof_basic1.phpt sizeof_basic2.phpt sizeof_error.phpt sizeof_object1.phpt sizeof_object2.phpt
sizeof_variation1.phpt sizeof_variation2.phpt sizeof_variation3.phpt sizeof_variation4.phpt sizeof_variation5.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-47220@lists.php.net to get a copy of this message
kraghuba Fri Nov 16 17:55:55 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/array sizeof_object2.phpt sizeof_basic1.phpt sizeof_basic2.phpt sizeof_error.phpt sizeof_variation1.phpt sizeof_variation2.phpt sizeof_variation3.phpt sizeof_variation4.phpt sizeof_variation5.phpt sizeof_object1.phpt Log: New testcases for sizeof() function

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_object2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_object2.phpt +++ php-src/ext/standard/tests/array/sizeof_object2.phpt --TEST-- Test sizeof() function : object functionality - objects without Countable interface --FILE-- <?php /* Prototype : int sizeof($mixed var[, int $mode] ) * Description: Counts an elements in an array. If Standard PHP library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ echo "*** Testing sizeof() : object functionality ***\n"; echo "--- Testing sizeof() with objects which doesn't implement Countable interface ---\n"; // class without member class test { // no members } // class with only members and with out member functions class test1 { public $member1; var $var1; private $member2; protected $member3; // no member functions } // class with only member functions class test2 { // no data members public function display() { echo " Class Name : test2\n"; } } // child class which inherits parent test2 class child_test2 extends test2 { public $child_member1; private $child_member2; } // abstract class abstract class abstract_class { public $member1; private $member2; abstract protected function display(); } // implement abstract 'abstract_class' class class concrete_class extends abstract_class { protected function display() { echo " class name is : concrete_class \n "; } } $objects = array ( /* 1 */ new test(), new test1(), new test2(), new child_test2(), /* 5 */ new concrete_class() ); $counter = 1; for($i = 0; $i < count($objects); $i++) { echo "-- Iteration $counter --\n"; $var = $objects[$i]; echo "Default Mode: "; var_dump( sizeof($var) ); echo "\n"; echo "COUNT_NORMAL Mode: "; var_dump( sizeof($var, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE Mode: "; var_dump( sizeof($var, COUNT_RECURSIVE) ); echo "\n"; $counter++; } echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : object functionality *** --- Testing sizeof() with objects which doesn't implement Countable interface --- -- Iteration 1 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 2 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 3 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 4 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 5 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) Done --UEXPECTF-- *** Testing sizeof() : object functionality *** --- Testing sizeof() with objects which doesn't implement Countable interface --- -- Iteration 1 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 2 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 3 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 4 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 5 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_basic1.phpt +++ php-src/ext/standard/tests/array/sizeof_basic1.phpt --TEST-- Test sizeof() function : basic functionality - for scalar types --FILE-- <?php /* Prototype : int sizeof(mixed $var[, int $mode] ) * Description: Counts an elements in an array. If Standard PHP library is * installed, it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ /* Testing the sizeof() for some of the scalar types(integer, float) values * in default, COUNT_NORMAL and COUNT_RECURSIVE modes. */ echo "*** Testing sizeof() : basic functionality ***\n"; $intval = 10; $floatval = 10.5; $stringval = "String"; echo "-- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --\n"; echo "default mode: "; var_dump( sizeof($intval) ); echo "\n"; echo "COUNT_NORMAL mode: "; var_dump( sizeof($intval, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE mode: "; var_dump( sizeof($intval, COUNT_RECURSIVE) ); echo "\n"; echo "-- Testing sizeof() for float type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --\n"; echo "default mode: "; var_dump( sizeof($floatval) ); echo "\n"; echo "COUNT_NORMAL mode: "; var_dump( sizeof($floatval, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE mode: "; var_dump( sizeof($floatval, COUNT_RECURSIVE) ); echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : basic functionality *** -- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- default mode: int(1) COUNT_NORMAL mode: int(1) COUNT_RECURSIVE mode: int(1) -- Testing sizeof() for float type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- default mode: int(1) COUNT_NORMAL mode: int(1) COUNT_RECURSIVE mode: int(1) Done --UEXPECTF-- *** Testing sizeof() : basic functionality *** -- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- default mode: int(1) COUNT_NORMAL mode: int(1) COUNT_RECURSIVE mode: int(1) -- Testing sizeof() for float type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- default mode: int(1) COUNT_NORMAL mode: int(1) COUNT_RECURSIVE mode: int(1) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_basic2.phpt +++ php-src/ext/standard/tests/array/sizeof_basic2.phpt --TEST-- Test sizeof() function : basic functionality - for non-scalar type(array) --FILE-- <?php /* Prototype : int sizeof(mixed $var[, int $mode] ) * Description: Counts an elements in an array. If Standard PHP library is * installed, it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ /* Testing the sizeof() for non-scalar type(array) value * in default, COUNT_NORMAL and COUNT_RECURSIVE modes. * Sizeof() has been tested for simple integer, string, * indexed and mixed arrays. */ echo "*** Testing sizeof() : basic functionality ***\n"; $int_array = array(1, 2, 3, 4); $string_array = array("Saffron", "White", "Green"); $indexed_array = array("Agression" => "Saffron", "Peace" => "White", "Growth" => "Green"); $mixed_array = array(1, 2, "Aggression" => "Saffron", 10 => "Ten", "Ten" => 10); echo "-- Testing sizeof() with integer array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n"; echo "default mode: "; var_dump( sizeof($int_array) ); echo "\n"; echo "COUNT_NORMAL mode: "; var_dump( sizeof($int_array, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE mode: "; var_dump( sizeof($int_array, COUNT_RECURSIVE) ); echo "\n"; echo "-- Testing sizeof() with string array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n"; echo "default mode: "; var_dump( sizeof($string_array) ); echo "\n"; echo "COUNT_NORMAL mode: "; var_dump( sizeof($string_array, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE mode: "; var_dump( sizeof($string_array, COUNT_RECURSIVE) ); echo "\n"; echo "-- Testing sizeof() with indexed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n"; echo "default mode: "; var_dump( sizeof($indexed_array) ); echo "\n"; echo "COUNT_NORMAL mode: "; var_dump( sizeof($indexed_array, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE mode: "; var_dump( sizeof($indexed_array, COUNT_RECURSIVE) ); echo "\n"; echo "-- Testing sizeof() with mixed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n"; echo "default mode: "; var_dump( sizeof($mixed_array) ); echo "\n"; echo "COUNT_NORMAL mode: "; var_dump( sizeof($mixed_array, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE mode: "; var_dump( sizeof($mixed_array, COUNT_RECURSIVE) ); echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : basic functionality *** -- Testing sizeof() with integer array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(4) COUNT_NORMAL mode: int(4) COUNT_RECURSIVE mode: int(4) -- Testing sizeof() with string array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(3) COUNT_NORMAL mode: int(3) COUNT_RECURSIVE mode: int(3) -- Testing sizeof() with indexed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(3) COUNT_NORMAL mode: int(3) COUNT_RECURSIVE mode: int(3) -- Testing sizeof() with mixed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(5) COUNT_NORMAL mode: int(5) COUNT_RECURSIVE mode: int(5) Done --UEXPECTF-- *** Testing sizeof() : basic functionality *** -- Testing sizeof() with integer array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(4) COUNT_NORMAL mode: int(4) COUNT_RECURSIVE mode: int(4) -- Testing sizeof() with string array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(3) COUNT_NORMAL mode: int(3) COUNT_RECURSIVE mode: int(3) -- Testing sizeof() with indexed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(3) COUNT_NORMAL mode: int(3) COUNT_RECURSIVE mode: int(3) -- Testing sizeof() with mixed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes -- default mode: int(5) COUNT_NORMAL mode: int(5) COUNT_RECURSIVE mode: int(5) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_error.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_error.phpt +++ php-src/ext/standard/tests/array/sizeof_error.phpt --TEST-- Test sizeof() function : error conditions --FILE-- <?php /* Prototype : int sizeof(mixed $var[, int $mode] ) * Description: Counts an elements in an array. If Standard PHP Library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ // Calling sizeof() with zero and more than expected arguments . echo "*** Testing sizeof() : error conditions ***\n"; echo "-- Testing sizeof() with zero arguments --\n"; var_dump( sizeof() ); echo "-- Testing sizeof() function with more than two arguments under COUNT_NORMAL mode --\n"; $var = 100; $extra_arg = 10;; var_dump( sizeof($var, COUNT_NORMAL, $extra_arg) ); echo "-- Testing sizeof() function with more than two arguments under COUNT_RECURSIVE mode --\n"; var_dump( sizeof($var, COUNT_RECURSIVE, $extra_arg) ); echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : error conditions *** -- Testing sizeof() with zero arguments -- Warning: sizeof() expects at least 1 parameter, 0 given in %s on line %d NULL -- Testing sizeof() function with more than two arguments under COUNT_NORMAL mode -- Warning: sizeof() expects at most 2 parameters, 3 given in %s on line %d NULL -- Testing sizeof() function with more than two arguments under COUNT_RECURSIVE mode -- Warning: sizeof() expects at most 2 parameters, 3 given in %s on line %d NULL Done --UEXPECTF-- *** Testing sizeof() : error conditions *** -- Testing sizeof() with zero arguments -- Warning: sizeof() expects at least 1 parameter, 0 given in %s on line %d NULL -- Testing sizeof() function with more than two arguments under COUNT_NORMAL mode -- Warning: sizeof() expects at most 2 parameters, 3 given in %s on line %d NULL -- Testing sizeof() function with more than two arguments under COUNT_RECURSIVE mode -- Warning: sizeof() expects at most 2 parameters, 3 given in %s on line %d NULL Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_variation1.phpt +++ php-src/ext/standard/tests/array/sizeof_variation1.phpt --TEST-- Test sizeof() function : usage variations - for all scalar types and resource variable --FILE-- <?php /* Prototype : int sizeof($mixed var[, int $mode]) * Description: Counts an elements in an array. If Standard PHP library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ echo "*** Testing sizeof() : usage variations ***\n"; echo "--- Testing sizeof() for all scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode ---\n"; // get a resource variable $fp = fopen(__FILE__, "r"); // array containing all scalar types $values = array ( // int values /* 1 */ 0, 1, // float values /* 3 */ 10.5, -10.5, 12.3456789000e10, 12.3456789000E-10, /* 7 */ .5, // NULL values /* 8 */ NULL, null, // boolean values /* 10 */ TRUE, FALSE, true, /* 13 */ false, // string data /* 14 */ "", '', "string", /* 17 */ 'string', // undefined variable @$undefined_var, // resource variable /* 19 */ $fp ); // loop through the each value of the array for 'var' argument and check the behaviour of sizeof() $counter = 1; for($i = 0; $i < count($values); $i++) { echo "-- Iteration $counter --\n"; $var = $values[$i]; echo "Default Mode: "; var_dump( sizeof($var) ); echo "\n"; echo "COUNT_NORMAL Mode: "; var_dump( sizeof($var, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE Mode: "; var_dump( sizeof($var, COUNT_RECURSIVE) ); echo "\n"; $counter++; } echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() for all scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode --- -- Iteration 1 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 2 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 3 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 4 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 5 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 6 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 7 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 8 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 9 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 10 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 11 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 12 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 13 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 14 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 15 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 16 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 17 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 18 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 19 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) Done --UEXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() for all scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode --- -- Iteration 1 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 2 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 3 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 4 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 5 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 6 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 7 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 8 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 9 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 10 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 11 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 12 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 13 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 14 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 15 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 16 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 17 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) -- Iteration 18 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 19 -- Default Mode: int(1) COUNT_NORMAL Mode: int(1) COUNT_RECURSIVE Mode: int(1) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_variation2.phpt +++ php-src/ext/standard/tests/array/sizeof_variation2.phpt --TEST-- Test sizeof() function : usage variations - different array values for 'var' argument --FILE-- <?php /* Prototype : int sizeof($mixed var[, int $mode]) * Description: Counts an elements in an array. If Standard PHP library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ echo "*** Testing sizeof() : usage variations ***\n"; // get a resource variable $fp = fopen(__FILE__, "r"); echo "--- Testing sizeof() with different array values for 'var' argument ---\n"; // array containing different types of array values for 'var' argument $values = array ( /* 1 */ array($fp, "resource" => $fp), array(1, array(3, 4, array(6, array(8)))), array("a" => 1, 'b' => 2, array( "c" =>3, array( "d" => 5))), array(), /* 5 */ array(1, 2, 3, 4), array("Saffron", "White", "Green"), array('saffron', 'white', 'green'), array(1 => "Hi", 2 => "Hello" ), array("color" => "red", "item" => "pen"), /* 10 */ array('color' => 'red', 'item' => 'pen'), array(TRUE => "red", FALSE => "pen" ), array(false => 'red', true => 'pen' ), array('color' => "red", "item" => 'pen', 1 => "Hi", "" => "Hello" ), /* 14 */ array($fp, "resource1" => $fp, 'resource2' => $fp, array( $fp, 'type' => $fp) ) ); // loop through each element of the values array for 'var' argument // check the working of sizeof() $counter = 1; for($i = 0; $i < count($values); $i++) { echo "-- Iteration $counter --\n"; $var = $values[$i]; echo "Default Mode: "; var_dump( sizeof($var) ); echo "\n"; echo "COUNT_NORMAL Mode: "; var_dump( sizeof($var, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE Mode: "; var_dump( sizeof($var, COUNT_RECURSIVE) ); echo "\n"; $counter++; } echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() with different array values for 'var' argument --- -- Iteration 1 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 2 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(8) -- Iteration 3 -- Default Mode: int(3) COUNT_NORMAL Mode: int(3) COUNT_RECURSIVE Mode: int(6) -- Iteration 4 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 5 -- Default Mode: int(4) COUNT_NORMAL Mode: int(4) COUNT_RECURSIVE Mode: int(4) -- Iteration 6 -- Default Mode: int(3) COUNT_NORMAL Mode: int(3) COUNT_RECURSIVE Mode: int(3) -- Iteration 7 -- Default Mode: int(3) COUNT_NORMAL Mode: int(3) COUNT_RECURSIVE Mode: int(3) -- Iteration 8 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 9 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 10 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 11 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 12 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 13 -- Default Mode: int(4) COUNT_NORMAL Mode: int(4) COUNT_RECURSIVE Mode: int(4) -- Iteration 14 -- Default Mode: int(4) COUNT_NORMAL Mode: int(4) COUNT_RECURSIVE Mode: int(6) Done --UEXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() with different array values for 'var' argument --- -- Iteration 1 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 2 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(8) -- Iteration 3 -- Default Mode: int(3) COUNT_NORMAL Mode: int(3) COUNT_RECURSIVE Mode: int(6) -- Iteration 4 -- Default Mode: int(0) COUNT_NORMAL Mode: int(0) COUNT_RECURSIVE Mode: int(0) -- Iteration 5 -- Default Mode: int(4) COUNT_NORMAL Mode: int(4) COUNT_RECURSIVE Mode: int(4) -- Iteration 6 -- Default Mode: int(3) COUNT_NORMAL Mode: int(3) COUNT_RECURSIVE Mode: int(3) -- Iteration 7 -- Default Mode: int(3) COUNT_NORMAL Mode: int(3) COUNT_RECURSIVE Mode: int(3) -- Iteration 8 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 9 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 10 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 11 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 12 -- Default Mode: int(2) COUNT_NORMAL Mode: int(2) COUNT_RECURSIVE Mode: int(2) -- Iteration 13 -- Default Mode: int(4) COUNT_NORMAL Mode: int(4) COUNT_RECURSIVE Mode: int(4) -- Iteration 14 -- Default Mode: int(4) COUNT_NORMAL Mode: int(4) COUNT_RECURSIVE Mode: int(6) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_variation3.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_variation3.phpt +++ php-src/ext/standard/tests/array/sizeof_variation3.phpt --TEST-- Test sizeof() function : usage variations - checking for infinite recursion in COUNT_RECURSIVE mode --FILE-- <?php /* Prototype : int sizeof($mixed var[, int $mode]) * Description: Counts an elements in an array. If Standard PHP library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ echo "*** Testing sizeof() : usage variations ***\n"; echo "-- Testing sizeof() for infinite recursion with arrays as argument in COUNT_RECURSIVE mode --\n"; $array2 = array ( "Hi", "Hello",@$a); $array3 = array( 'hi', 'hello'); $a = array ( 1, @$array1, $array2, $array3); $array1 = array( array(1, 2), $a); $array4 = array( 100, @$array4); var_dump( sizeof($array1, COUNT_RECURSIVE) ); echo "\n"; var_dump( sizeof($array4, COUNT_RECURSIVE) ); echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : usage variations *** -- Testing sizeof() for infinite recursion with arrays as argument in COUNT_RECURSIVE mode -- int(13) int(2) Done --UEXPECTF-- *** Testing sizeof() : usage variations *** -- Testing sizeof() for infinite recursion with arrays as argument in COUNT_RECURSIVE mode -- int(13) int(2) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_variation4.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_variation4.phpt +++ php-src/ext/standard/tests/array/sizeof_variation4.phpt --TEST-- Test sizeof() function : usage variations - all kinds of unset variables for 'var' argument --FILE-- <?php /* Prototype : int sizeof($mixed var[, int $mode]) * Description: Counts an elements in an array. If Standard PHP library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ echo "*** Testing sizeof() : usage variations ***\n"; echo "--- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes ---\n"; // class declaration class test { public $member1; } // get an resource variable $fp = fopen(__FILE__, "r"); // array containing different types of variables $values = array ( // int values /* 1 */ 0, 1, // float values /* 3 */ 10.5, -10.5, 12.34e3, /* 6 */ 12.34E-3, // string values /* 7 */ "string", 'string', "", /* 10 */ '', // NULL values /* 11 */ NULL, null, // Boolean Values /* 12 */ TRUE, true, false, /* 16 */ FALSE, // array values /* 17 */ array(), array(1, 2, 3,4 , array(5, 6)), // object variable /* 19 */ new test(), // resource variable /* 20 */ $fp ); // loop through the each element of the $values array for 'var' arugment // and check the functionality of sizeof() $counter = 1; foreach($values as $value) { echo "-- Iteration $counter --\n"; // unset the variable unset($value); // now check the size of unset variable when different modes are given echo "Default Mode: "; var_dump( sizeof($value) ); echo "\n"; echo "COUNT_NORMAL Mode: "; var_dump( sizeof($value, COUNT_NORMAL) ); echo "\n"; echo "COUNT_RECURSIVE Mode: "; var_dump( sizeof($value, COUNT_RECURSIVE) ); echo "\n"; $counter++; } fclose($fp); echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes --- -- Iteration 1 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 2 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 3 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 4 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 5 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 6 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 7 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 8 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 9 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 10 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 11 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 12 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 13 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 14 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 15 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 16 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 17 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 18 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 19 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 20 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) Done --UEXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes --- -- Iteration 1 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 2 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 3 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 4 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 5 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 6 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 7 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 8 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 9 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 10 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 11 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 12 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 13 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 14 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 15 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 16 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 17 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 18 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 19 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) -- Iteration 20 -- Default Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d int(0) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_variation5.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_variation5.phpt +++ php-src/ext/standard/tests/array/sizeof_variation5.phpt --TEST-- Test sizeof() function : usage variations - different values for 'mode' argument --FILE-- <?php /* Prototype : int sizeof($mixed var[, int $mode]) * Description: Counts an elements in an array. If Standard PHP library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ echo "*** Testing sizeof() : usage variations ***\n"; echo "--- Testing sizeof() with different values for 'mode' argument ---\n"; $array1 = array(1, 2, 3, 4, array(1.0, 2.0, array()), array() ); // get a resource variable $fp = fopen(__FILE__, "r"); //unset variable $unset_var = 10; unset($unset_var); //class declaration class test { public $member1; } $mode_values = array ( /* 1 */ COUNT_NORMAL, COUNT_RECURSIVE, 0, // same as COUNT_NORMAL 1, // same as COUNT_RECURSIVE /* 5 */ TRUE, // same as COUNT_RECURSIVE true, // same as COUNT_RECURSIVE FALSE, // same as COUNT_NORMAL false, // same as COUNT_NORMAL NULL, // same as COUNT_NORMAL /* 10 */ null, // same as COUNT_NORMAL 100, 10.5, 12.34e3, 12.34E-2, /* 15 */ .5, "", '', "string", 'string', /* 20 */ @$unset_var, new test(), /* 22 */ $fp ); // loop through the each element of $modes_array for 'mode' argument // and check the working of sizeof() $counter = 1; for($i = 0; $i < count($mode_values); $i++) { echo "-- Iteration $counter --\n"; $mode = $mode_values[$i]; var_dump( sizeof($array1, $mode) ); $counter++; } fclose($fp); echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() with different values for 'mode' argument --- -- Iteration 1 -- int(6) -- Iteration 2 -- int(9) -- Iteration 3 -- int(6) -- Iteration 4 -- int(9) -- Iteration 5 -- int(9) -- Iteration 6 -- int(9) -- Iteration 7 -- int(6) -- Iteration 8 -- int(6) -- Iteration 9 -- int(6) -- Iteration 10 -- int(6) -- Iteration 11 -- int(6) -- Iteration 12 -- int(6) -- Iteration 13 -- int(6) -- Iteration 14 -- int(6) -- Iteration 15 -- int(6) -- Iteration 16 -- Warning: sizeof() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 17 -- Warning: sizeof() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 18 -- Warning: sizeof() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 19 -- Warning: sizeof() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 20 -- int(6) -- Iteration 21 -- Warning: sizeof() expects parameter 2 to be long, object given in %s on line %d NULL -- Iteration 22 -- Warning: sizeof() expects parameter 2 to be long, resource given in %s on line %d NULL Done --UEXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() with different values for 'mode' argument --- -- Iteration 1 -- int(6) -- Iteration 2 -- int(9) -- Iteration 3 -- int(6) -- Iteration 4 -- int(9) -- Iteration 5 -- int(9) -- Iteration 6 -- int(9) -- Iteration 7 -- int(6) -- Iteration 8 -- int(6) -- Iteration 9 -- int(6) -- Iteration 10 -- int(6) -- Iteration 11 -- int(6) -- Iteration 12 -- int(6) -- Iteration 13 -- int(6) -- Iteration 14 -- int(6) -- Iteration 15 -- int(6) -- Iteration 16 -- Warning: sizeof() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 17 -- Warning: sizeof() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 18 -- Warning: sizeof() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 19 -- Warning: sizeof() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 20 -- int(6) -- Iteration 21 -- Warning: sizeof() expects parameter 2 to be long, object given in %s on line %d NULL -- Iteration 22 -- Warning: sizeof() expects parameter 2 to be long, resource given in %s on line %d NULL Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/sizeof_object1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/sizeof_object1.phpt +++ php-src/ext/standard/tests/array/sizeof_object1.phpt --TEST-- Test sizeof() function : objects - object with Countable interface --SKIPIF-- <?php // Skip the test case if Standard PHP Library(spl) is not installed if( !extension_loaded('spl') ) { die('skip SPL not installed'); } ?> --FILE-- <?php /* Prototype : int sizeof($mixed var[, int $mode]) * Description: Counts an elements in an array. If Standard PHP library is installed, * it will return the properties of an object. * Source code: ext/standard/basic_functions.c * Alias to functions: count() */ echo "*** Testing sizeof() with object functionality ***\n"; echo "-- Testing sizeof() with an object which implements Countable interface --\n"; class sizeof_class implements Countable { public $member1; private $member2; protected $member3; public function count() { return 3; // return the count of member variables in the object } } $obj = new sizeof_class(); echo "-- Testing sizeof() in default mode --\n"; var_dump( sizeof($obj) ); echo "-- Testing sizeof() in COUNT_NORMAL mode --\n"; var_dump( sizeof($obj, COUNT_NORMAL) ); echo "-- Testing sizeof() in COUNT_RECURSIVE mode --\n"; var_dump( sizeof($obj, COUNT_RECURSIVE) ); echo "Done"; ?> --EXPECTF-- *** Testing sizeof() with object functionality *** -- Testing sizeof() with an object which implements Countable interface -- -- Testing sizeof() in default mode -- int(3) -- Testing sizeof() in COUNT_NORMAL mode -- int(3) -- Testing sizeof() in COUNT_RECURSIVE mode -- int(3) Done --UEXPECTF-- *** Testing sizeof() with object functionality *** -- Testing sizeof() with an object which implements Countable interface -- -- Testing sizeof() in default mode -- int(3) -- Testing sizeof() in COUNT_NORMAL mode -- int(3) -- Testing sizeof() in COUNT_RECURSIVE mode -- int(3) Done
« previous php.cvs (#47220) next »