cvs: php-src /ext/standard/tests/general_functions debug_zval_dump_b.phpt debug_zval_dump_e.phpt debug_zval_dump_o.phpt debug_zval_dump_v.phpt
is_array.phpt is_bool.phpt is_float.phpt is_int.phpt is_null.phpt is_numeric.phpt is_object.phpt is_scalar.phpt is_string.phpt print_r.phpt
strval.phpt var_dump.phpt

From: Date: Sat, 12 May 2007 12:18:13 +0000
Subject: cvs: php-src /ext/standard/tests/general_functions debug_zval_dump_b.phpt debug_zval_dump_e.phpt debug_zval_dump_o.phpt debug_zval_dump_v.phpt
is_array.phpt is_bool.phpt is_float.phpt is_int.phpt is_null.phpt is_numeric.phpt is_object.phpt is_scalar.phpt is_string.phpt print_r.phpt
strval.phpt var_dump.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-44278@lists.php.net to get a copy of this message
kraghuba Sat May 12 12:18:13 2007 UTC Modified files: /php-src/ext/standard/tests/general_functions is_int.phpt is_scalar.phpt print_r.phpt is_string.phpt debug_zval_dump_o.phpt is_float.phpt is_numeric.phpt var_dump.phpt debug_zval_dump_e.phpt debug_zval_dump_v.phpt is_bool.phpt strval.phpt is_array.phpt is_null.phpt is_object.phpt debug_zval_dump_b.phpt Log: New version of debug_zval_dump_b.phpt, debug_zval_dump_v.phpt, is_float.phpt, is_numeric.phpt, is_string.phpt, var_dump.phpt, debug_zval_dump_e.phpt, is_array.phpt, is_int.phpt, is_object.phpt, print_r.phpt, debug_zval_dump_o.phpt, is_bool.phpt, is_null.phpt, is_scalar.phpt, strval.phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_int.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_int.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_int.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_int.phpt Sat May 12 12:18:12 2007 @@ -0,0 +1,448 @@ +--TEST-- +Test is_int() & it's FALIASes: is_long() & is_integer() functions +--FILE-- +<?php +/* Prototype: bool is_int ( mixed $var ); + * Description: Finds whether the given variable is an integer + */ + +echo "*** Testing is_int(), is_integer() & is_long() with valid integer values ***\n"; +// different valid integer vlaues +$valid_ints = array( + 0, + 1, + -1, + -2147483647, + 2147483647, // max positive integer value + 2147483640, + 0x123B, // integer as hexadecimal + 0x12ab, + 0Xfff, + 0XFA, + 0x7fffffff, // max postive integer as hexadecimal + 0x7FFFFFFF, // max postive integer as hexadecimal + 0123, // integer as octal + 01912, // should be quivalent to octal 1 + 017777777777, // max positive integer as octal +); +/* loop to check that is_int() recognizes different + integer values, expected output: bool(true) */ +$loop_counter = 1; +foreach ($valid_ints as $int_val ) { + echo "--Iteration $loop_counter--\n"; $loop_counter++; + var_dump( is_int($int_val) ); + var_dump( is_integer($int_val) ); + var_dump( is_long($int_val) ); +} + +echo "\n*** Testing is_int(), is_integer() & is_long() with non integer values ***\n"; + +// resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); +// unset variable + +$unset_var = 10; +unset ($unset_var); + +// other types in a array +$not_int_types = array ( + /* float values */ + -2147483649, // float value + 2147483648, // float value + -0x80000001, // float value, beyond max negative int + 0x800000001, // float value, beyond max positive int + 020000000001, // float value, beyond max positive int + -020000000001, // float value, beyond max negative int + 0.0, + -0.1, + 1.0, + 1e5, + -1e6, + 1E8, + -1E9, + 10.0000000000000000005, + 10.5e+5, + + /* objects */ + new stdclass, + + /* resources */ + $fp, + $dfp, + + /* arrays */ + array(), + array(0), + array(1), + array(NULL), + array(null), + array("string"), + array(true), + array(TRUE), + array(false), + array(FALSE), + array(1,2,3,4), + array(1 => "One", "two" => 2), + + /* strings */ + "", + '', + "0", + '0', + "1", + '1', + "\x01", + '\x01', + "\01", + '\01', + 'string', + "string", + "true", + "FALSE", + 'false', + 'TRUE', + "NULL", + 'null', + + /* booleans */ + true, + false, + TRUE, + FALSE, + + /* undefined and unset vars */ + @$unset_var, + @$undefined_var +); +/* loop through the $not_int_types to see working of + is_int() on non integer types, expected output: bool(false) */ +$loop_counter = 1; +foreach ($not_int_types as $type ) { + echo "--Iteration $loop_counter--\n"; $loop_counter++; + var_dump( is_int($type) ); + var_dump( is_integer($type) ); + var_dump( is_long($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_int() ); +var_dump( is_integer() ); +var_dump( is_long() ); + +//arguments more than expected +var_dump( is_int(TRUE, FALSE) ); +var_dump( is_integer(TRUE, FALSE) ); +var_dump( is_long(TRUE, FALSE) ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_int(), is_integer() & is_long() with valid integer values *** +--Iteration 1-- +bool(true) +bool(true) +bool(true) +--Iteration 2-- +bool(true) +bool(true) +bool(true) +--Iteration 3-- +bool(true) +bool(true) +bool(true) +--Iteration 4-- +bool(true) +bool(true) +bool(true) +--Iteration 5-- +bool(true) +bool(true) +bool(true) +--Iteration 6-- +bool(true) +bool(true) +bool(true) +--Iteration 7-- +bool(true) +bool(true) +bool(true) +--Iteration 8-- +bool(true) +bool(true) +bool(true) +--Iteration 9-- +bool(true) +bool(true) +bool(true) +--Iteration 10-- +bool(true) +bool(true) +bool(true) +--Iteration 11-- +bool(true) +bool(true) +bool(true) +--Iteration 12-- +bool(true) +bool(true) +bool(true) +--Iteration 13-- +bool(true) +bool(true) +bool(true) +--Iteration 14-- +bool(true) +bool(true) +bool(true) +--Iteration 15-- +bool(true) +bool(true) +bool(true) + +*** Testing is_int(), is_integer() & is_long() with non integer values *** +--Iteration 1-- +bool(false) +bool(false) +bool(false) +--Iteration 2-- +bool(false) +bool(false) +bool(false) +--Iteration 3-- +bool(false) +bool(false) +bool(false) +--Iteration 4-- +bool(false) +bool(false) +bool(false) +--Iteration 5-- +bool(false) +bool(false) +bool(false) +--Iteration 6-- +bool(false) +bool(false) +bool(false) +--Iteration 7-- +bool(false) +bool(false) +bool(false) +--Iteration 8-- +bool(false) +bool(false) +bool(false) +--Iteration 9-- +bool(false) +bool(false) +bool(false) +--Iteration 10-- +bool(false) +bool(false) +bool(false) +--Iteration 11-- +bool(false) +bool(false) +bool(false) +--Iteration 12-- +bool(false) +bool(false) +bool(false) +--Iteration 13-- +bool(false) +bool(false) +bool(false) +--Iteration 14-- +bool(false) +bool(false) +bool(false) +--Iteration 15-- +bool(false) +bool(false) +bool(false) +--Iteration 16-- +bool(false) +bool(false) +bool(false) +--Iteration 17-- +bool(false) +bool(false) +bool(false) +--Iteration 18-- +bool(false) +bool(false) +bool(false) +--Iteration 19-- +bool(false) +bool(false) +bool(false) +--Iteration 20-- +bool(false) +bool(false) +bool(false) +--Iteration 21-- +bool(false) +bool(false) +bool(false) +--Iteration 22-- +bool(false) +bool(false) +bool(false) +--Iteration 23-- +bool(false) +bool(false) +bool(false) +--Iteration 24-- +bool(false) +bool(false) +bool(false) +--Iteration 25-- +bool(false) +bool(false) +bool(false) +--Iteration 26-- +bool(false) +bool(false) +bool(false) +--Iteration 27-- +bool(false) +bool(false) +bool(false) +--Iteration 28-- +bool(false) +bool(false) +bool(false) +--Iteration 29-- +bool(false) +bool(false) +bool(false) +--Iteration 30-- +bool(false) +bool(false) +bool(false) +--Iteration 31-- +bool(false) +bool(false) +bool(false) +--Iteration 32-- +bool(false) +bool(false) +bool(false) +--Iteration 33-- +bool(false) +bool(false) +bool(false) +--Iteration 34-- +bool(false) +bool(false) +bool(false) +--Iteration 35-- +bool(false) +bool(false) +bool(false) +--Iteration 36-- +bool(false) +bool(false) +bool(false) +--Iteration 37-- +bool(false) +bool(false) +bool(false) +--Iteration 38-- +bool(false) +bool(false) +bool(false) +--Iteration 39-- +bool(false) +bool(false) +bool(false) +--Iteration 40-- +bool(false) +bool(false) +bool(false) +--Iteration 41-- +bool(false) +bool(false) +bool(false) +--Iteration 42-- +bool(false) +bool(false) +bool(false) +--Iteration 43-- +bool(false) +bool(false) +bool(false) +--Iteration 44-- +bool(false) +bool(false) +bool(false) +--Iteration 45-- +bool(false) +bool(false) +bool(false) +--Iteration 46-- +bool(false) +bool(false) +bool(false) +--Iteration 47-- +bool(false) +bool(false) +bool(false) +--Iteration 48-- +bool(false) +bool(false) +bool(false) +--Iteration 49-- +bool(false) +bool(false) +bool(false) +--Iteration 50-- +bool(false) +bool(false) +bool(false) +--Iteration 51-- +bool(false) +bool(false) +bool(false) +--Iteration 52-- +bool(false) +bool(false) +bool(false) +--Iteration 53-- +bool(false) +bool(false) +bool(false) +--Iteration 54-- +bool(false) +bool(false) +bool(false) + +*** Testing error conditions *** + +Warning: is_int() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_integer() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_long() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_int() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: is_integer() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: is_long() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_scalar.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_scalar.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_scalar.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_scalar.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,241 @@ +--TEST-- +Test is_scalar() function +--FILE-- +<?php +/* Prototype: bool is_scalar ( mixed $var ); + * Description: Finds whether a variable is a scalar (i.e integer, float, string or boolean) + */ + +echo "*** Testing basic operations ***\n"; +$scalar_variables = array( + 0, // integers + 1, + -45678, + 0x5FF, // hexadecimal as integer + 0X566, + -0xAAF, + -0XCCF, + 01234, // octal as integer + -0126, + + 0.0, // floats + -1.0, + 1e5, + -1e7, + 1.6E7, + 475.e-8, + 784.e+30, + 98.45E+40, + .5E-40, + + "", // strings + '', + " ", + ' ', + "string", + 'string', + "0", // numeric as string + "40", + "50.696", + "0x534", + "0X534", + + TRUE, // boolean + FALSE, + true, + false +); +/* loop through each valid scalar variables in $scalar_variables + and see the working of is_scalar(), expected output: bool(true) +*/ +$loop_counter = 1; +foreach($scalar_variables as $scalar) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_scalar($scalar) ); +} + +echo "\n*** Testing possible variations ***\n"; +// different scalar variables which are unset +$int_var = 10; +$float_var = 1e5; +$string_var = "string"; +$boolean_var = true; +$object = new stdclass; +$array = array(10); +$resource = opendir('.'); +unset($int_var, $float_var, $string_var, $boolean_var, $object, $array, $resource); + +// resources +$fp = fopen(__FILE__, "r"); +$dfp = opendir("."); + +$variation_array = array( + NULL, + null, + + array(), // arrays + array(NULL), + array(true), + array(0), + array(1,2,3,4), + + $fp, // resources + $dfp, + + new stdclass, // object + + @$int_var, // scalars that are unset + @$float_var, + @$string_var, + @$boolean_var, + + @$array, // non scalars that are unset + @$object, + @$resource, + + @$undefined_var // undefined variable +); + +/* loop through each element of $variation_array to see the + working of is_scalar on non-scalar values, expected output: bool(false) +*/ +$loop_counter = 1; +foreach( $variation_array as $value ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_scalar($value) ); +} + +echo "\n*** Testing error conditions ***\n"; +// Zero arguments +var_dump( is_scalar() ); + +// Arguments more than expected +var_dump( is_scalar( $scalar_variables[2], $scalar_variables[2]) ); +var_dump( is_scalar( new stdclass, new stdclass) ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources used +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing basic operations *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) +-- Iteration 11 -- +bool(true) +-- Iteration 12 -- +bool(true) +-- Iteration 13 -- +bool(true) +-- Iteration 14 -- +bool(true) +-- Iteration 15 -- +bool(true) +-- Iteration 16 -- +bool(true) +-- Iteration 17 -- +bool(true) +-- Iteration 18 -- +bool(true) +-- Iteration 19 -- +bool(true) +-- Iteration 20 -- +bool(true) +-- Iteration 21 -- +bool(true) +-- Iteration 22 -- +bool(true) +-- Iteration 23 -- +bool(true) +-- Iteration 24 -- +bool(true) +-- Iteration 25 -- +bool(true) +-- Iteration 26 -- +bool(true) +-- Iteration 27 -- +bool(true) +-- Iteration 28 -- +bool(true) +-- Iteration 29 -- +bool(true) +-- Iteration 30 -- +bool(true) +-- Iteration 31 -- +bool(true) +-- Iteration 32 -- +bool(true) +-- Iteration 33 -- +bool(true) + +*** Testing possible variations *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) + +*** Testing error conditions *** + +Warning: Wrong parameter count for is_scalar() in %s on line %d +NULL + +Warning: Wrong parameter count for is_scalar() in %s on line %d +NULL + +Warning: Wrong parameter count for is_scalar() in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/print_r.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/print_r.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/print_r.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/print_r.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,1787 @@ +--TEST-- +Test print_r() function +--FILE-- + +<?php +/* Prototype: bool print_r ( mixed $expression [, bool $return] ); + Description: Prints human-readable information about a variable +*/ + +/* Prototype: void check_printr( $variables ) + Description: use print_r() to print variables */ +function check_printr( $variables ) { + $counter = 1; + foreach( $variables as $variable ) { + echo "\n-- Iteration $counter --\n"; + //default = false, prints output to screen + print_r($variable); + //$return=TRUE, print_r() will return its output, instead of printing it + $ret_string = print_r($variable, true); //$ret_string captures the output + echo "\n$ret_string\n"; + //$return=false, print_r() prints the output; default behavior + print_r($variable, false); + $counter++; + } +} + +echo "\n*** Testing print_r() on integer variables ***\n"; +$integers = array ( + 0, // zero as argument + 000000123, //octal value of 83 + 123000000, + -00000123, //octal value of 83 + -12300000, + range(1,10), // positive values + range(-1,-10), // negative values + +2147483647, // max positive integer + +2147483648, // max positive integer + 1 + -2147483648, // min range of integer + -2147483647, // min range of integer + 1 + 0x7FFFFFFF, // max positive hexadecimal integer + -0x80000000, // min range of hexadecimal integer + 017777777777, // max posotive octal integer + -020000000000 // min range of octal integer +); +/* calling check_printr() to display contents of integer variables + using print_r() */ +check_printr($integers); + +echo "\n*** Testing print_r() on float variables ***\n"; +$floats = array ( + -0.0, + +0.0, + 1.234, + -1.234, + -2.000000, + 000002.00, + -.5, + .567, + -.6700000e-3, + -.6700000E+3, + .6700000E+3, + .6700000e+3, + -4.10003e-3, + -4.10003E+3, + 4.100003e-3, + 4.100003E+3, + 1e5, + -1e5, + 1e-5, + -1e-5, + 1e+5, + -1e+5, + 1E5, + -1E5, + 1E+5, + -1E+5, + 1E-5, + -1E-5, + -0x80000001, // float value, beyond max negative int + 0x80000001, // float value, beyond max positive int + 020000000001, // float value, beyond max positive int + -020000000001 // float value, beyond max negative int +); +/* calling check_printr() to display contents of float variables + using print_r() */ +check_printr($floats); + +echo "\n*** Testing print_r() on string variables ***\n"; +$strings = array ( + "", + '', + " ", + ' ', + "0", + "\0", + '\0', + "\t", + '\t', + "PHP", + 'PHP', + "abcd\x0n1234\x0005678\x0000efgh\xijkl", // strings with hexadecimal NULL + "abcd\0efgh\0ijkl\x00mnop\x000qrst\00uvwx\0000yz", // strings with octal NULL + "1234\t\n5678\n\t9100\rabcda" // strings with escape characters +); +/* calling check_printr() to display contents of strings using print_r() */ +check_printr($strings); + +echo "\n*** Testing print_r() on boolean variables ***\n"; +$booleans = array ( + TRUE, + FALSE, + true, + false +); +/* calling check_printr() to display boolean variables using print_r() */ +check_printr($booleans); +var_dump( reset($booleans) ); +echo "\n"; +var_dump( current($booleans) ); + +echo "\n*** Testing print_r() on array variables ***\n"; +$arrays = array ( + array(), + array(NULL), + array(null), + array(true), + array(""), + array(''), + array(array(), array()), + array(array(1, 2), array('a', 'b')), + array(1 => 'One'), + array("test" => "is_array"), + array(0), + array(-1), + array(10.5, 5.6), + array("string", "test"), + array('string', 'test'), + $array1 = array(1,2,3,4, &$array1) // recursive array +); +/* calling check_printr() to display contents of $arrays */ +check_printr($arrays); + +echo "\n*** Testing print_r() on object variables ***\n"; +class object_class +{ + var $value; + public $public_var1 = 10; + private $private_var1 = 20; + private $private_var2; + protected $protected_var1 = "string_1"; + protected $protected_var2; + + function object_class ( ) { + $this->value = 50; + $this->public_var2 = 11; + $this->private_var2 = 21; + $this->protected_var2 = "string_2"; + } + + public function foo1() { + echo "foo1() is called\n"; + } + protected function foo2() { + echo "foo2() is called\n"; + } + private function foo3() { + echo "foo3() is called\n"; + } +} +/* class with no member */ +class no_member_class { + // no members +} + +/* class with member as object of other class */ +class contains_object_class +{ + var $p = 30; + var $class_object1; + public $class_object2; + private $class_object3; + protected $class_object4; + var $no_member_class_object; + + public function func() { + echo "func() is called \n"; + } + + function contains_object_class () { + $this->class_object1 = new object_class(); + $this->class_object2 = new object_class(); + $this->class_object3 = $this->class_object1; + $this->class_object4 = $this->class_object2; + $this->no_member_class_object = new no_member_class(); + $this->class_object5 = $this; //recursive reference + } +} + +/* objects of different classes */ +$obj = new contains_object_class; +$temp_class_obj = new object_class(); + +/* object which is unset */ +$unset_obj = new object_class(); +unset($unset_obj); + +$objects = array ( + new object_class, + new no_member_class, + new contains_object_class, + $obj, + $obj->class_object1, + $obj->class_object2, + $obj->no_member_class_object, + $temp_class_obj, + @$unset_obj +); +/* calling check_printr() to display contents of the objects using print_r() */ +check_printr($objects); + +echo "\n** Testing print_r() on objects having circular reference **\n"; +$recursion_obj1 = new object_class(); +$recursion_obj2 = new object_class(); +$recursion_obj1->obj = &$recursion_obj2; //circular reference +$recursion_obj2->obj = &$recursion_obj1; //circular reference +print_r($recursion_obj2); + +echo "\n*** Testing print_r() on resources ***\n"; +/* file type resource */ +$file_handle = fopen(__FILE__, "r"); + +/* directory type resource */ +$dir_handle = opendir( dirname(__FILE__) ); + +$resources = array ( + $file_handle, + $dir_handle +); +/* calling check_printr() to display the resource content type + using print_r() */ +check_printr($resources); + +echo "\n*** Testing print_r() on different combinations of scalar + and non-scalar variables ***\n"; +/* a variable which is unset */ +$unset_var = 10.5; +unset($unset_var); + +/* unset file type resource */ +unset($file_handle); + +$variations = array ( + array( 123, -1.2345, "a" ), + array( "d", array(1, 3, 5), true, null), + array( new no_member_class, array(), false, 0 ), + array( -0.00, "Where am I?", array(7,8,9), TRUE, 'A', 987654321 ), + array( @$unset_var, 2.E+10, 100-20.9, 000004.599998 ), //unusual data + array( "array(1,2,3,4)1.0000002TRUE", @$file_handle, 111333.00+45e5, '/00\7') +); +/* calling check_printr() to display combinations of scalar and + non-scalar variables using print_r() */ +check_printr($variations); + +echo "\n*** Testing print_r() on miscelleneous input arguments ***\n"; +$misc_values = array ( + @$unset_var, + NULL, // NULL argument + @$undef_variable, //undefined variable + null +); +/* calling check_printr() to display miscelleneous data using print_r() */ +check_printr($misc_values); + +/* checking print_r() on functions */ +echo "\n*** Testing print_r() on anonymous functions ***\n"; +$newfunc = create_function('$a,$b', 'return "$a * $b = " . ($a * $b);'); +echo "New anonymous function: $newfunc\n"; +print_r( $newfunc(2, 3) ); +/* creating anonymous function dynamically */ +print_r( create_function('$a', 'return "$a * $a = " . ($a * $b);') ); + +echo "\n\n*** Testing error conditions ***\n"; +//passing zero argument +var_dump( print_r() ); + +//passing more than required no. of arguments +var_dump( print_r(123, true, "abc") ); + +// check when second arg is given other than boolean TRUE +var_dump( print_r ($value, "string") ); + +/* closing resource handle used */ +closedir($dir_handle); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing print_r() on integer variables *** + +-- Iteration 1 -- +0 +0 +0 +-- Iteration 2 -- +83 +83 +83 +-- Iteration 3 -- +123000000 +123000000 +123000000 +-- Iteration 4 -- +-83 +-83 +-83 +-- Iteration 5 -- +-12300000 +-12300000 +-12300000 +-- Iteration 6 -- +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => 5 + [5] => 6 + [6] => 7 + [7] => 8 + [8] => 9 + [9] => 10 +) + +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => 5 + [5] => 6 + [6] => 7 + [7] => 8 + [8] => 9 + [9] => 10 +) + +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => 5 + [5] => 6 + [6] => 7 + [7] => 8 + [8] => 9 + [9] => 10 +) + +-- Iteration 7 -- +Array +( + [0] => -1 + [1] => -2 + [2] => -3 + [3] => -4 + [4] => -5 + [5] => -6 + [6] => -7 + [7] => -8 + [8] => -9 + [9] => -10 +) + +Array +( + [0] => -1 + [1] => -2 + [2] => -3 + [3] => -4 + [4] => -5 + [5] => -6 + [6] => -7 + [7] => -8 + [8] => -9 + [9] => -10 +) + +Array +( + [0] => -1 + [1] => -2 + [2] => -3 + [3] => -4 + [4] => -5 + [5] => -6 + [6] => -7 + [7] => -8 + [8] => -9 + [9] => -10 +) + +-- Iteration 8 -- +2147483647 +2147483647 +2147483647 +-- Iteration 9 -- +2147483648 +2147483648 +2147483648 +-- Iteration 10 -- +-2147483648 +-2147483648 +-2147483648 +-- Iteration 11 -- +-2147483647 +-2147483647 +-2147483647 +-- Iteration 12 -- +2147483647 +2147483647 +2147483647 +-- Iteration 13 -- +-2147483648 +-2147483648 +-2147483648 +-- Iteration 14 -- +2147483647 +2147483647 +2147483647 +-- Iteration 15 -- +-2147483648 +-2147483648 +-2147483648 +*** Testing print_r() on float variables *** + +-- Iteration 1 -- +0 +0 +0 +-- Iteration 2 -- +0 +0 +0 +-- Iteration 3 -- +1.234 +1.234 +1.234 +-- Iteration 4 -- +-1.234 +-1.234 +-1.234 +-- Iteration 5 -- +-2 +-2 +-2 +-- Iteration 6 -- +2 +2 +2 +-- Iteration 7 -- +-0.5 +-0.5 +-0.5 +-- Iteration 8 -- +0.567 +0.567 +0.567 +-- Iteration 9 -- +-0.00067 +-0.00067 +-0.00067 +-- Iteration 10 -- +-670 +-670 +-670 +-- Iteration 11 -- +670 +670 +670 +-- Iteration 12 -- +670 +670 +670 +-- Iteration 13 -- +-0.00410003 +-0.00410003 +-0.00410003 +-- Iteration 14 -- +-4100.03 +-4100.03 +-4100.03 +-- Iteration 15 -- +0.004100003 +0.004100003 +0.004100003 +-- Iteration 16 -- +4100.003 +4100.003 +4100.003 +-- Iteration 17 -- +100000 +100000 +100000 +-- Iteration 18 -- +-100000 +-100000 +-100000 +-- Iteration 19 -- +1.0E-5 +1.0E-5 +1.0E-5 +-- Iteration 20 -- +-1.0E-5 +-1.0E-5 +-1.0E-5 +-- Iteration 21 -- +100000 +100000 +100000 +-- Iteration 22 -- +-100000 +-100000 +-100000 +-- Iteration 23 -- +100000 +100000 +100000 +-- Iteration 24 -- +-100000 +-100000 +-100000 +-- Iteration 25 -- +100000 +100000 +100000 +-- Iteration 26 -- +-100000 +-100000 +-100000 +-- Iteration 27 -- +1.0E-5 +1.0E-5 +1.0E-5 +-- Iteration 28 -- +-1.0E-5 +-1.0E-5 +-1.0E-5 +-- Iteration 29 -- +-2147483649 +-2147483649 +-2147483649 +-- Iteration 30 -- +2147483649 +2147483649 +2147483649 +-- Iteration 31 -- +2147483649 +2147483649 +2147483649 +-- Iteration 32 -- +-2147483649 +-2147483649 +-2147483649 +*** Testing print_r() on string variables *** + +-- Iteration 1 -- + + + +-- Iteration 2 -- + + + +-- Iteration 3 -- + + + +-- Iteration 4 -- + + + +-- Iteration 5 -- +0 +0 +0 +-- Iteration 6 -- ++++-- Iteration 7 -- +\0 +\0 +\0 +-- Iteration 8 -- + + + +-- Iteration 9 -- +\t +\t +\t +-- Iteration 10 -- +PHP +PHP +PHP +-- Iteration 11 -- +PHP +PHP +PHP +-- Iteration 12 -- +abcd+abcd+abcd+-- Iteration 13 -- +abcd+abcd+abcd+-- Iteration 14 -- +1234 +5678 + 9100abcda +1234 +5678 + 9100abcda +1234 +5678 + 9100abcda +*** Testing print_r() on boolean variables *** + +-- Iteration 1 -- +1 +1 +1 +-- Iteration 2 -- + + + +-- Iteration 3 -- +1 +1 +1 +-- Iteration 4 -- + + +bool(true) + +bool(true) + +*** Testing print_r() on array variables *** + +-- Iteration 1 -- +Array +( +) + +Array +( +) + +Array +( +) + +-- Iteration 2 -- +Array +( + [0] => +) + +Array +( + [0] => +) + +Array +( + [0] => +) + +-- Iteration 3 -- +Array +( + [0] => +) + +Array +( + [0] => +) + +Array +( + [0] => +) + +-- Iteration 4 -- +Array +( + [0] => 1 +) + +Array +( + [0] => 1 +) + +Array +( + [0] => 1 +) + +-- Iteration 5 -- +Array +( + [0] => +) + +Array +( + [0] => +) + +Array +( + [0] => +) + +-- Iteration 6 -- +Array +( + [0] => +) + +Array +( + [0] => +) + +Array +( + [0] => +) + +-- Iteration 7 -- +Array +( + [0] => Array + ( + ) + + [1] => Array + ( + ) + +) + +Array +( + [0] => Array + ( + ) + + [1] => Array + ( + ) + +) + +Array +( + [0] => Array + ( + ) + + [1] => Array + ( + ) + +) + +-- Iteration 8 -- +Array +( + [0] => Array + ( + [0] => 1 + [1] => 2 + ) + + [1] => Array + ( + [0] => a + [1] => b + ) + +) + +Array +( + [0] => Array + ( + [0] => 1 + [1] => 2 + ) + + [1] => Array + ( + [0] => a + [1] => b + ) + +) + +Array +( + [0] => Array + ( + [0] => 1 + [1] => 2 + ) + + [1] => Array + ( + [0] => a + [1] => b + ) + +) + +-- Iteration 9 -- +Array +( + [1] => One +) + +Array +( + [1] => One +) + +Array +( + [1] => One +) + +-- Iteration 10 -- +Array +( + [test] => is_array +) + +Array +( + [test] => is_array +) + +Array +( + [test] => is_array +) + +-- Iteration 11 -- +Array +( + [0] => 0 +) + +Array +( + [0] => 0 +) + +Array +( + [0] => 0 +) + +-- Iteration 12 -- +Array +( + [0] => -1 +) + +Array +( + [0] => -1 +) + +Array +( + [0] => -1 +) + +-- Iteration 13 -- +Array +( + [0] => 10.5 + [1] => 5.6 +) + +Array +( + [0] => 10.5 + [1] => 5.6 +) + +Array +( + [0] => 10.5 + [1] => 5.6 +) + +-- Iteration 14 -- +Array +( + [0] => string + [1] => test +) + +Array +( + [0] => string + [1] => test +) + +Array +( + [0] => string + [1] => test +) + +-- Iteration 15 -- +Array +( + [0] => string + [1] => test +) + +Array +( + [0] => string + [1] => test +) + +Array +( + [0] => string + [1] => test +) + +-- Iteration 16 -- +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => Array + ( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => Array + *RECURSION* + ) + +) + +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => Array + ( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => Array + *RECURSION* + ) + +) + +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => Array + ( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => Array + *RECURSION* + ) + +) + +*** Testing print_r() on object variables *** + +-- Iteration 1 -- +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +-- Iteration 2 -- +no_member_class Object +( +) + +no_member_class Object +( +) + +no_member_class Object +( +) + +-- Iteration 3 -- +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) + +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) + +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) + +-- Iteration 4 -- +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) + +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) + +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) + +-- Iteration 5 -- +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +-- Iteration 6 -- +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +-- Iteration 7 -- +no_member_class Object +( +) + +no_member_class Object +( +) + +no_member_class Object +( +) + +-- Iteration 8 -- +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +-- Iteration 9 -- + + + +** Testing print_r() on objects having circular reference ** +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + [obj] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + [obj] => object_class Object + *RECURSION* + ) + +) + +*** Testing print_r() on resources *** + +-- Iteration 1 -- +Resource id #%d +Resource id #%d +Resource id #%d +-- Iteration 2 -- +Resource id #%d +Resource id #%d +Resource id #%d +*** Testing print_r() on different combinations of scalar + and non-scalar variables *** + +-- Iteration 1 -- +Array +( + [0] => 123 + [1] => -1.2345 + [2] => a +) + +Array +( + [0] => 123 + [1] => -1.2345 + [2] => a +) + +Array +( + [0] => 123 + [1] => -1.2345 + [2] => a +) + +-- Iteration 2 -- +Array +( + [0] => d + [1] => Array + ( + [0] => 1 + [1] => 3 + [2] => 5 + ) + + [2] => 1 + [3] => +) + +Array +( + [0] => d + [1] => Array + ( + [0] => 1 + [1] => 3 + [2] => 5 + ) + + [2] => 1 + [3] => +) + +Array +( + [0] => d + [1] => Array + ( + [0] => 1 + [1] => 3 + [2] => 5 + ) + + [2] => 1 + [3] => +) + +-- Iteration 3 -- +Array +( + [0] => no_member_class Object + ( + ) + + [1] => Array + ( + ) + + [2] => + [3] => 0 +) + +Array +( + [0] => no_member_class Object + ( + ) + + [1] => Array + ( + ) + + [2] => + [3] => 0 +) + +Array +( + [0] => no_member_class Object + ( + ) + + [1] => Array + ( + ) + + [2] => + [3] => 0 +) + +-- Iteration 4 -- +Array +( + [0] => 0 + [1] => Where am I? + [2] => Array + ( + [0] => 7 + [1] => 8 + [2] => 9 + ) + + [3] => 1 + [4] => A + [5] => 987654321 +) + +Array +( + [0] => 0 + [1] => Where am I? + [2] => Array + ( + [0] => 7 + [1] => 8 + [2] => 9 + ) + + [3] => 1 + [4] => A + [5] => 987654321 +) + +Array +( + [0] => 0 + [1] => Where am I? + [2] => Array + ( + [0] => 7 + [1] => 8 + [2] => 9 + ) + + [3] => 1 + [4] => A + [5] => 987654321 +) + +-- Iteration 5 -- +Array +( + [0] => + [1] => 20000000000 + [2] => 79.1 + [3] => 4.599998 +) + +Array +( + [0] => + [1] => 20000000000 + [2] => 79.1 + [3] => 4.599998 +) + +Array +( + [0] => + [1] => 20000000000 + [2] => 79.1 + [3] => 4.599998 +) + +-- Iteration 6 -- +Array +( + [0] => array(1,2,3,4)1.0000002TRUE + [1] => + [2] => 4611333 + [3] => /00\7 +) + +Array +( + [0] => array(1,2,3,4)1.0000002TRUE + [1] => + [2] => 4611333 + [3] => /00\7 +) + +Array +( + [0] => array(1,2,3,4)1.0000002TRUE + [1] => + [2] => 4611333 + [3] => /00\7 +) + +*** Testing print_r() on miscelleneous input arguments *** + +-- Iteration 1 -- + + + +-- Iteration 2 -- + + + +-- Iteration 3 -- + + + +-- Iteration 4 -- + + + +*** Testing print_r() on anonymous functions *** +New anonymous function: +2 * 3 = 6+ +*** Testing error conditions *** + +Warning: print_r() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: print_r() expects at most 2 parameters, 3 given in %s on line %d +bool(false) + +Notice: Undefined variable: value in %s on line %d +string(0) "" +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_string.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_string.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_string.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_string.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,304 @@ +--TEST-- +Test is_string() function +--FILE-- +<?php +/* Prototype: bool is_string ( mixed $var ); + * Description: Finds whether the given variable is a string + */ + +echo "*** Testing is_string() with valid string values ***\n"; +// different valid strings + +/* string created using Heredoc (<<<) */ +$heredoc_string = <<<EOT +This is string defined +using heredoc. +EOT; +/* heredoc string with only numerics */ +$heredoc_numeric_string = <<<EOT +123456 3993 +4849 string +EOT; +/* null heardoc string */ +$heredoc_empty_string = <<<EOT +EOT; +$heredoc_null_string = <<<EOT +NULL +EOT; + +$strings = array( + "", + " ", + '', + ' ', + "string", + 'string', + "NULL", + 'null', + "FALSE", + 'true', + "\x0b", + "\0", + '\0', + '\060', + "\070", + "0x55F", + "055", + "@#$#$%%$^^$%^%^$^&", + $heredoc_string, + $heredoc_numeric_string, + $heredoc_empty_string, + $heredoc_null_string +); +/* loop to check that is_string() recognizes different + strings, expected output bool(true) */ +$loop_counter = 1; +foreach ($strings as $string ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_string($string) ); +} + +echo "\n*** Testing is_string() on non string values ***\n"; + +// get a resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); + +// unset vars +$unset_string1 = "string"; +$unset_string2 = 'string'; +$unset_heredoc = <<<EOT +this is heredoc string +EOT; +// unset the vars +unset($unset_string1, $unset_string2, $unset_heredoc); + +// other types in a array +$not_strings = array ( + /* integers */ + 0, + 1, + -1, + -0, + 543915, + -5322, + 0x0, + 0x1, + 0x55F, + -0xCCF, + 0123, + -0654, + 00, + 01, + + /* floats */ + 0.0, + 1.0, + -1.0, + 10.0000000000000000005, + .5e6, + -.5E7, + .5E+8, + -.5e+90, + 1e5, + -1e5, + 1E5, + -1E7, + + /* objects */ + new stdclass, + + /* resources */ + $fp, + $dfp, + + /* arrays */ + array(), + array(0), + array(1), + array(NULL), + array(null), + array("string"), + array(true), + array(TRUE), + array(false), + array(FALSE), + array(1,2,3,4), + array(1 => "One", "two" => 2), + + /* undefined and unset vars */ + @$unset_string1, + @$unset_string2, + @$unset_heredoc, + @$undefined_var +); +/* loop through the $not_strings to see working of + is_string() on non string types, expected output bool(false) */ +$loop_counter = 1; +foreach ($not_strings as $type ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_string($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_string() ); + +//arguments more than expected +var_dump( is_string("string", "test") ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources used +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_string() with valid string values *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) +-- Iteration 11 -- +bool(true) +-- Iteration 12 -- +bool(true) +-- Iteration 13 -- +bool(true) +-- Iteration 14 -- +bool(true) +-- Iteration 15 -- +bool(true) +-- Iteration 16 -- +bool(true) +-- Iteration 17 -- +bool(true) +-- Iteration 18 -- +bool(true) +-- Iteration 19 -- +bool(true) +-- Iteration 20 -- +bool(true) +-- Iteration 21 -- +bool(true) +-- Iteration 22 -- +bool(true) + +*** Testing is_string() on non string values *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +-- Iteration 27 -- +bool(false) +-- Iteration 28 -- +bool(false) +-- Iteration 29 -- +bool(false) +-- Iteration 30 -- +bool(false) +-- Iteration 31 -- +bool(false) +-- Iteration 32 -- +bool(false) +-- Iteration 33 -- +bool(false) +-- Iteration 34 -- +bool(false) +-- Iteration 35 -- +bool(false) +-- Iteration 36 -- +bool(false) +-- Iteration 37 -- +bool(false) +-- Iteration 38 -- +bool(false) +-- Iteration 39 -- +bool(false) +-- Iteration 40 -- +bool(false) +-- Iteration 41 -- +bool(false) +-- Iteration 42 -- +bool(false) +-- Iteration 43 -- +bool(false) +-- Iteration 44 -- +bool(false) +-- Iteration 45 -- +bool(false) + +*** Testing error conditions *** + +Warning: is_string(): Only one argument expected in %s on line %d +bool(false) + +Warning: is_string(): Only one argument expected in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/debug_zval_dump_o.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/debug_zval_dump_o.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/debug_zval_dump_o.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/debug_zval_dump_o.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,839 @@ +--TEST-- +Test debug_zval_dump() function : working on objects +--FILE-- +<?php +/* Prototype: void debug_zval_dump ( mixed $variable ); + Description: Dumps a string representation of an internal zend value to output. +*/ + +/* Prototype: void zval_dump( $value ); + Description: use debug_zval_dump() to display the objects and its + reference count */ +function zval_dump( $values ) { + $counter = 1; + foreach( $values as $value ) { + echo "-- Iteration $counter --\n"; + debug_zval_dump( $value ); + $counter++; + } +} + +/* checking on objects type */ +echo "*** Testing debug_zval_dump() on objects ***\n"; +class object_class { + var $value1 = 1; + private $value2 = 10; + protected $value3 = 20; + public $value4 = 30; + + private function foo1() { + echo "function foo1\n"; + } + protected function foo2() { + echo "function foo2\n"; + } + public function foo3() { + echo "function foo3\n"; + } + public $array_var = array( "key1" => 1, "key2 " => 3); + + function object_class () { + $this->value1 = 5; + $this->object_class1 = $this; + } +} + +class no_member_class{ +//no members +} + +/* class with member as object of other class */ +class contains_object_class +{ + var $p = 30; + protected $p1 = 40; + private $p2 = 50; + var $class_object1; + public $class_object2; + private $class_object3; + protected $class_object4; + var $no_member_class_object; + + public function func() { + echo "func() is called \n"; + } + + function contains_object_class () { + $this->class_object1 = new object_class(); + $this->class_object2 = new object_class(); + $this->class_object3 = $this->class_object1; + $this->class_object4 = $this->class_object2; + $this->no_member_class_object = new no_member_class(); + $this->class_object5 = $this; //recursive reference + } +} + +/* creating new object $obj */ +$obj = new contains_object_class(); +$obj1 = & $obj; //object $obj1 references object $obj +$obj2 = & $obj; +$obj3 = & $obj2; + +/* object which is unset */ +$unset_obj = new object_class(); +unset($unset_obj); + +$objects = array ( + new object_class, + new no_member_class, + $obj, + $obj->class_object1, + $obj->class_object2, + $obj->no_member_class_object, + @$temp_class_obj, //undefined object + $obj2->class_object1, + $obj3->class_object2, + $obj2->class_object1->value4, + @$unset_obj +); +/* using zval_dump() to dump out the objects and its reference count */ +zval_dump($objects); + +$int_var = 500; +$obj = $int_var; //$obj is lost, $obj1,$obj2,$obj3,$obj4 = 500 +echo "\n-- Testing debug_zval_dump() on overwritten object variables --\n"; +debug_zval_dump($obj, $obj1, $obj2, $obj3); + +echo "\n-- Testing debug_zval_dump() on objects having circular reference --\n"; +$recursion_obj1 = new object_class(); +$recursion_obj2 = new object_class(); +$recursion_obj1->obj = &$recursion_obj2; //circular reference +$recursion_obj2->obj = &$recursion_obj1; //circular reference +debug_zval_dump($recursion_obj2); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing debug_zval_dump() on objects *** +-- Iteration 1 -- +object(object_class)#%d (6) refcount(4){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(4){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } +} +-- Iteration 2 -- +object(no_member_class)#%d (0) refcount(3){ +} +-- Iteration 3 -- +object(contains_object_class)#%d (9) refcount(3){ + ["p"]=> + long(30) refcount(2) + ["p1":protected]=> + long(40) refcount(2) + ["p2":"contains_object_class":private]=> + long(50) refcount(2) + ["class_object1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["class_object2"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["class_object4":protected]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) refcount(2){ + } + ["class_object5"]=> + object(contains_object_class)#%d (9) refcount(1){ + ["p"]=> + long(30) refcount(2) + ["p1":protected]=> + long(40) refcount(2) + ["p2":"contains_object_class":private]=> + long(50) refcount(2) + ["class_object1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["class_object2"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["class_object4":protected]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(5){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) refcount(2){ + } + ["class_object5"]=> + *RECURSION* + } +} +-- Iteration 4 -- +object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } +} +-- Iteration 5 -- +object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } +} +-- Iteration 6 -- +object(no_member_class)#%d (0) refcount(4){ +} +-- Iteration 7 -- +NULL refcount(1) +-- Iteration 8 -- +object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } +} +-- Iteration 9 -- +object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (6) refcount(7){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(5) + ["value3":protected]=> + long(20) refcount(5) + ["value4"]=> + long(30) refcount(6) + ["array_var"]=> + array(2) refcount(5){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + } +} +-- Iteration 10 -- +long(30) refcount(8) +-- Iteration 11 -- +NULL refcount(1) + +-- Testing debug_zval_dump() on overwritten object variables -- +long(500) refcount(1) +long(500) refcount(1) +long(500) refcount(1) +long(500) refcount(1) + +-- Testing debug_zval_dump() on objects having circular reference -- +object(object_class)#%d (7) refcount(1){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (7) refcount(1){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + ["obj"]=> + &object(object_class)#%d (7) refcount(2){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (7) refcount(1){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + ["obj"]=> + *RECURSION* + } + ["obj"]=> + *RECURSION* + } + } + ["obj"]=> + &object(object_class)#%d (7) refcount(2){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + object(object_class)#%d (7) refcount(1){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + ["obj"]=> + &object(object_class)#%d (7) refcount(2){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + ["obj"]=> + *RECURSION* + } + } + ["obj"]=> + &object(object_class)#%d (7) refcount(2){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + ["obj"]=> + &object(object_class)#%d (7) refcount(2){ + ["value1"]=> + long(5) refcount(1) + ["value2":"object_class":private]=> + long(10) refcount(7) + ["value3":protected]=> + long(20) refcount(7) + ["value4"]=> + long(30) refcount(8) + ["array_var"]=> + array(2) refcount(7){ + ["key1"]=> + long(1) refcount(1) + ["key2 "]=> + long(3) refcount(1) + } + ["object_class1"]=> + *RECURSION* + ["obj"]=> + *RECURSION* + } + } + } +} +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_float.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_float.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_float.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_float.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,437 @@ +--TEST-- +Test is_float() & it's FALIAS: is_double() & is_real() functions +--FILE-- +<?php +/* Prototype: bool is_float ( mixed $var ); + * Description: Finds whether the given variable is a float + */ + +echo "*** Testing is_float(), is_double() and is_real() with float values***\n"; +// different valid float vlaues +$floats = array( + -2147483649, // float value + 2147483648, // float value + -0x80000001, // float value, beyond max negative int + 0x800000001, // float value, beyond max positive int + 020000000001, // float value, beyond max positive int + -020000000001, // float value, beyond max negative int + 0.0, + -0.1, + 10.0000000000000000005, + 10.5e+5, + 1e5, + -1e5, + 1e-5, + -1e-5, + 1e+5, + -1e+5, + 1E5, + -1E5, + 1E+5, + -1E+5, + 1E-5, + -1E-5, + .5e+7, + -.5e+7, + .6e-19, + -.6e-19, + .05E+44, + -.05E+44, + .0034E-30, + -.0034E-30 +); +/* loop to check that is_float(), is_double() & is_real() recognizes + different float values, expected: bool(true) */ +$loop_counter = 1; +foreach ($floats as $float ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_float($float) ); + var_dump( is_double($float) ); + var_dump( is_real($float) ); +} + +echo "\n*** Testing is_float(), is_double() & is_real() with non float values ***\n"; +// get a resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); + +// unset variable +$unset_var = 10; +unset ($unset_var); + +// non_scalar values, objects, arrays, resources and boolean +class foo +{ + var $array = array(10.5); +}; +$object = new foo(); + +$not_floats = array ( + new foo, //object + $object, + + $fp, // resource + $dfp, + + array(), // arrays + array(NULL), + array(0.5e10), + array(1,2,3,4), + array("string"), + + NULL, // nulls + null, + + true, // boolean + TRUE, + false, + FALSE, + + "", // strings + '', + "0", + '0', + "0.0", + '0.0', + '0.5', + "-0.5", + "1e5", + '1e5', + '1.5e6_string', + "1.5e6_string", + + 1, // integers, hex and octal + -1, + 0, + 12345, + 0xFF55, + -0x673, + 0123, + -0123, + + @$unset_var, // unset variable + @$undefined_var +); +/* loop through the $not_floats to see working of + is_float(), is_double() & is_real() on objects, + arrays, boolean and others */ +$loop_counter = 1; +foreach ($not_floats as $value ) { + echo "--Iteration $loop_counter--\n"; $loop_counter++; + var_dump( is_float($value) ); + var_dump( is_double($value) ); + var_dump( is_real($value) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_float() ); +var_dump( is_double() ); +var_dump( is_real() ); + +//arguments more than expected +var_dump( is_float( $floats[0], $floats[1]) ); +var_dump( is_double( $floats[0], $floats[1]) ); +var_dump( is_real( $floats[0], $floats[1]) ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources used +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_float(), is_double() and is_real() with float values*** +-- Iteration 1 -- +bool(true) +bool(true) +bool(true) +-- Iteration 2 -- +bool(true) +bool(true) +bool(true) +-- Iteration 3 -- +bool(true) +bool(true) +bool(true) +-- Iteration 4 -- +bool(true) +bool(true) +bool(true) +-- Iteration 5 -- +bool(true) +bool(true) +bool(true) +-- Iteration 6 -- +bool(true) +bool(true) +bool(true) +-- Iteration 7 -- +bool(true) +bool(true) +bool(true) +-- Iteration 8 -- +bool(true) +bool(true) +bool(true) +-- Iteration 9 -- +bool(true) +bool(true) +bool(true) +-- Iteration 10 -- +bool(true) +bool(true) +bool(true) +-- Iteration 11 -- +bool(true) +bool(true) +bool(true) +-- Iteration 12 -- +bool(true) +bool(true) +bool(true) +-- Iteration 13 -- +bool(true) +bool(true) +bool(true) +-- Iteration 14 -- +bool(true) +bool(true) +bool(true) +-- Iteration 15 -- +bool(true) +bool(true) +bool(true) +-- Iteration 16 -- +bool(true) +bool(true) +bool(true) +-- Iteration 17 -- +bool(true) +bool(true) +bool(true) +-- Iteration 18 -- +bool(true) +bool(true) +bool(true) +-- Iteration 19 -- +bool(true) +bool(true) +bool(true) +-- Iteration 20 -- +bool(true) +bool(true) +bool(true) +-- Iteration 21 -- +bool(true) +bool(true) +bool(true) +-- Iteration 22 -- +bool(true) +bool(true) +bool(true) +-- Iteration 23 -- +bool(true) +bool(true) +bool(true) +-- Iteration 24 -- +bool(true) +bool(true) +bool(true) +-- Iteration 25 -- +bool(true) +bool(true) +bool(true) +-- Iteration 26 -- +bool(true) +bool(true) +bool(true) +-- Iteration 27 -- +bool(true) +bool(true) +bool(true) +-- Iteration 28 -- +bool(true) +bool(true) +bool(true) +-- Iteration 29 -- +bool(true) +bool(true) +bool(true) +-- Iteration 30 -- +bool(true) +bool(true) +bool(true) + +*** Testing is_float(), is_double() & is_real() with non float values *** +--Iteration 1-- +bool(false) +bool(false) +bool(false) +--Iteration 2-- +bool(false) +bool(false) +bool(false) +--Iteration 3-- +bool(false) +bool(false) +bool(false) +--Iteration 4-- +bool(false) +bool(false) +bool(false) +--Iteration 5-- +bool(false) +bool(false) +bool(false) +--Iteration 6-- +bool(false) +bool(false) +bool(false) +--Iteration 7-- +bool(false) +bool(false) +bool(false) +--Iteration 8-- +bool(false) +bool(false) +bool(false) +--Iteration 9-- +bool(false) +bool(false) +bool(false) +--Iteration 10-- +bool(false) +bool(false) +bool(false) +--Iteration 11-- +bool(false) +bool(false) +bool(false) +--Iteration 12-- +bool(false) +bool(false) +bool(false) +--Iteration 13-- +bool(false) +bool(false) +bool(false) +--Iteration 14-- +bool(false) +bool(false) +bool(false) +--Iteration 15-- +bool(false) +bool(false) +bool(false) +--Iteration 16-- +bool(false) +bool(false) +bool(false) +--Iteration 17-- +bool(false) +bool(false) +bool(false) +--Iteration 18-- +bool(false) +bool(false) +bool(false) +--Iteration 19-- +bool(false) +bool(false) +bool(false) +--Iteration 20-- +bool(false) +bool(false) +bool(false) +--Iteration 21-- +bool(false) +bool(false) +bool(false) +--Iteration 22-- +bool(false) +bool(false) +bool(false) +--Iteration 23-- +bool(false) +bool(false) +bool(false) +--Iteration 24-- +bool(false) +bool(false) +bool(false) +--Iteration 25-- +bool(false) +bool(false) +bool(false) +--Iteration 26-- +bool(false) +bool(false) +bool(false) +--Iteration 27-- +bool(false) +bool(false) +bool(false) +--Iteration 28-- +bool(false) +bool(false) +bool(false) +--Iteration 29-- +bool(false) +bool(false) +bool(false) +--Iteration 30-- +bool(false) +bool(false) +bool(false) +--Iteration 31-- +bool(false) +bool(false) +bool(false) +--Iteration 32-- +bool(false) +bool(false) +bool(false) +--Iteration 33-- +bool(false) +bool(false) +bool(false) +--Iteration 34-- +bool(false) +bool(false) +bool(false) +--Iteration 35-- +bool(false) +bool(false) +bool(false) +--Iteration 36-- +bool(false) +bool(false) +bool(false) +--Iteration 37-- +bool(false) +bool(false) +bool(false) + +*** Testing error conditions *** + +Warning: is_float() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_double() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_real() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_float() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: is_double() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: is_real() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_numeric.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_numeric.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_numeric.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_numeric.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,388 @@ +--TEST-- +Test is_numeric() function +--FILE-- +<?php +/* Prototype: bool is_numeric ( mixed $var ); + * Description: Finds whether a variable is a number or a numeric string + */ + +echo "*** Testing is_numeric() with valid numeric values ***\n"; +// different valid numeric vlaues +$numerics = array( + 0, + 1, + -1, + -0, + +0, + 0.0, + -0.0, + +0.0, + 1.0, + -1.0, + +1.0, + .5, + -.5, + +.5, + -.5e-2, + .5e-2, + +.5e-2, + +.5E+2, + 0.70000000, + +0.70000000, + -0.70000000, + 1234567890123456, + -1234567890123456, + 984847472827282718178, + -984847472827282718178, + 123.56e30, + 123.56E30, + 426.45e-30, + 5657.3E-40, + 3486.36e+40, + 3486.36E+90, + -3486.36E+10, + -3486.36e+80, + -426.45e-50, + -426.45E-99, + 1e2, + -1e2, + -1e-2, + +1e2, + +1e+2, + +1e-2, + +1e+2, + 2245555555555555.444, + 1.444444444444444444, + 0xff, // hexa decimal numbers + 0xFF, + //0x1111111111111111111111, + -0x1111111, + +0x6698319, + 01000000000000000000000, + 0123, + 0345900, + -0200001, + -0200001.7, + 0200001.7, + +0200001, + +0200001.7, + +0200001.7, + 2.00000000000000000000001, // a float value with more precision points + "1", // numeric in the form of string + "-1", + "1e2", + " 1", + "2974394749328742328432", + "-1e-2", + '1', + '-1', + '1e2', + ' 1', + '2974394749328742328432', + '-1e-2', + "0xff", + '0xff', + "0123", + '0123', + "-0123", + "+0123", + '-0123', + '+0123' +); +/* loop to check that is_numeric() recognizes different + numeric values, expected output: bool(true) */ +$loop_counter = 1; +foreach ($numerics as $num ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_numeric($num) ); +} + +echo "\n*** Testing is_numeric() on non numeric types ***\n"; + +// get a resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); + +// unset variable +$unset_var = 10.5; +unset ($unset_var); + +// other types in a array +$not_numerics = array( + "-0x80001", + "+0x80001", + "-0x80001.5", + "0x80001.5", + new stdclass, // object + $fp, // resource + $dfp, + array(), + array("string"), + "", + "1 ", + "- 1", + "1.2.4", + "1e7.6", + "3FF", + "20 test", + "3.6test", + "1,000", + "NULL", + "true", + true, + NULL, + null, + TRUE, + FALSE, + false, + @$unset_var, // unset variable + @$undefined_var +); +/* loop through the $not_numerics to see working of + is_numeric() on non numeric values, expected output: bool(false) */ +$loop_counter = 1; +foreach ($not_numerics as $type ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_numeric($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_numeric() ); + +//arguments more than expected +var_dump( is_numeric("10", "20") ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources used +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_numeric() with valid numeric values *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) +-- Iteration 11 -- +bool(true) +-- Iteration 12 -- +bool(true) +-- Iteration 13 -- +bool(true) +-- Iteration 14 -- +bool(true) +-- Iteration 15 -- +bool(true) +-- Iteration 16 -- +bool(true) +-- Iteration 17 -- +bool(true) +-- Iteration 18 -- +bool(true) +-- Iteration 19 -- +bool(true) +-- Iteration 20 -- +bool(true) +-- Iteration 21 -- +bool(true) +-- Iteration 22 -- +bool(true) +-- Iteration 23 -- +bool(true) +-- Iteration 24 -- +bool(true) +-- Iteration 25 -- +bool(true) +-- Iteration 26 -- +bool(true) +-- Iteration 27 -- +bool(true) +-- Iteration 28 -- +bool(true) +-- Iteration 29 -- +bool(true) +-- Iteration 30 -- +bool(true) +-- Iteration 31 -- +bool(true) +-- Iteration 32 -- +bool(true) +-- Iteration 33 -- +bool(true) +-- Iteration 34 -- +bool(true) +-- Iteration 35 -- +bool(true) +-- Iteration 36 -- +bool(true) +-- Iteration 37 -- +bool(true) +-- Iteration 38 -- +bool(true) +-- Iteration 39 -- +bool(true) +-- Iteration 40 -- +bool(true) +-- Iteration 41 -- +bool(true) +-- Iteration 42 -- +bool(true) +-- Iteration 43 -- +bool(true) +-- Iteration 44 -- +bool(true) +-- Iteration 45 -- +bool(true) +-- Iteration 46 -- +bool(true) +-- Iteration 47 -- +bool(true) +-- Iteration 48 -- +bool(true) +-- Iteration 49 -- +bool(true) +-- Iteration 50 -- +bool(true) +-- Iteration 51 -- +bool(true) +-- Iteration 52 -- +bool(true) +-- Iteration 53 -- +bool(true) +-- Iteration 54 -- +bool(true) +-- Iteration 55 -- +bool(true) +-- Iteration 56 -- +bool(true) +-- Iteration 57 -- +bool(true) +-- Iteration 58 -- +bool(true) +-- Iteration 59 -- +bool(true) +-- Iteration 60 -- +bool(true) +-- Iteration 61 -- +bool(true) +-- Iteration 62 -- +bool(true) +-- Iteration 63 -- +bool(true) +-- Iteration 64 -- +bool(true) +-- Iteration 65 -- +bool(true) +-- Iteration 66 -- +bool(true) +-- Iteration 67 -- +bool(true) +-- Iteration 68 -- +bool(true) +-- Iteration 69 -- +bool(true) +-- Iteration 70 -- +bool(true) +-- Iteration 71 -- +bool(true) +-- Iteration 72 -- +bool(true) +-- Iteration 73 -- +bool(true) +-- Iteration 74 -- +bool(true) +-- Iteration 75 -- +bool(true) +-- Iteration 76 -- +bool(true) +-- Iteration 77 -- +bool(true) +-- Iteration 78 -- +bool(true) + +*** Testing is_numeric() on non numeric types *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +-- Iteration 27 -- +bool(false) +-- Iteration 28 -- +bool(false) + +*** Testing error conditions *** + +Warning: Wrong parameter count for is_numeric() in %s on line %d +NULL + +Warning: Wrong parameter count for is_numeric() in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/var_dump.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/var_dump.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/var_dump.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/var_dump.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,1977 @@ +--TEST-- +Test var_dump() function +--FILE-- + +<?php +/* Prototype: void var_dump ( mixed $expression [, mixed $expression [, $...]] ); + Description: Displays structured information about one or more expressions that includes its type and value. +*/ + +/* Prototype: void check_vardump( $variables ); + Description: use var_dump() to display the variables */ +function check_vardump( $variables ) { + $counter = 1; + foreach( $variables as $variable ) { + echo "-- Iteration $counter --\n"; + var_dump( $variable ); + $counter++; + } +} + +echo "\n*** Testing var_dump() on integer variables ***\n"; +$integers = array ( + 0, // zero as argument + 000000123, //octal value of 83 + 123000000, + -00000123, //octal value of 83 + -12300000, + range(1,10), // positive values + range(-1,-10), // negative values + +2147483647, // max positive integer + +2147483648, // max positive integer + 1 + -2147483648, // min range of integer + -2147483647, // min range of integer + 1 + 0x7FFFFFFF, // max positive hexadecimal integer + -0x80000000, // min range of hexadecimal integer + 017777777777, // max posotive octal integer + -020000000000 // min range of octal integer +); +/* calling check_vardump() to display contents of integer variables + using var_dump() */ +check_vardump($integers); + +echo "\n*** Testing var_dump() on float variables ***\n"; +$floats = array ( + -0.0, + +0.0, + 1.234, + -1.234, + -2.000000, + 000002.00, + -.5, + .567, + -.6700000e-3, + -.6700000E+3, + .6700000E+3, + .6700000e+3, + -4.10003e-3, + -4.10003E+3, + 4.100003e-3, + 4.100003E+3, + 1e5, + -1e5, + 1e-5, + -1e-5, + 1e+5, + -1e+5, + 1E5, + -1E5, + 1E+5, + -1E+5, + 1E-5, + -1E-5, + -0x80000001, // float value, beyond max negative int + 0x80000001, // float value, beyond max positive int + 020000000001, // float value, beyond max positive int + -020000000001 // float value, beyond max negative int +); +/* calling check_vardump() to display contents of float variables + using var_dump() */ +check_vardump($floats); + +echo "\n*** Testing var_dump() on string variables ***\n"; +$strings = array ( + "", + '', + " ", + ' ', + "0", + "\0", + '\0', + "\t", + '\t', + "PHP", + 'PHP', + "abcd\x0n1234\x0005678\x0000efgh\xijkl", // strings with hexadecimal NULL + "abcd\0efgh\0ijkl\x00mnop\x000qrst\00uvwx\0000yz", // strings with octal NULL + "1234\t\n5678\n\t9100\rabcda" // strings with escape characters +); +/* calling check_vardump() to display contents of strings + using var_dump() */ +check_vardump($strings); + +echo "\n*** Testing var_dump() on boolean variables ***\n"; +$booleans = array ( + TRUE, + FALSE, + true, + false +); +/* calling check_vardump() to display boolean variables + using var_dump() */ +check_vardump($booleans); + +echo "\n*** Testing var_dump() on array variables ***\n"; +$arrays = array ( + array(), + array(NULL), + array(null), + array(true), + array(""), + array(''), + array(array(), array()), + array(array(1, 2), array('a', 'b')), + array(1 => 'One'), + array("test" => "is_array"), + array(0), + array(-1), + array(10.5, 5.6), + array("string", "test"), + array('string', 'test'), + $array1 = array(1,2,3,4, &$array1) // recursive array +); +/* calling check_vardump() to display contents of an array + using var_dump() */ +check_vardump($arrays); + +echo "\n*** Testing var_dump() on object variables ***\n"; +class object_class +{ + var $value; + public $public_var1 = 10; + private $private_var1 = 20; + private $private_var2; + protected $protected_var1 = "string_1"; + protected $protected_var2; + + function object_class ( ) { + $this->value = 50; + $this->public_var2 = 11; + $this->private_var2 = 21; + $this->protected_var2 = "string_2"; + } + + public function foo1() { + echo "foo1() is called\n"; + } + protected function foo2() { + echo "foo2() is called\n"; + } + private function foo3() { + echo "foo3() is called\n"; + } +} +/* class with no member */ +class no_member_class { + // no members +} + +/* class with member as object of other class */ +class contains_object_class +{ + var $p = 30; + var $class_object1; + public $class_object2; + private $class_object3; + protected $class_object4; + var $no_member_class_object; + + public function func() { + echo "func() is called \n"; + } + + function contains_object_class () { + $this->class_object1 = new object_class(); + $this->class_object2 = new object_class(); + $this->class_object3 = $this->class_object1; + $this->class_object4 = $this->class_object2; + $this->no_member_class_object = new no_member_class(); + $this->class_object5 = $this; //recursive reference + } +} + +/* objects of different classes */ +$obj = new contains_object_class; +$temp_class_obj = new object_class(); + +/* object which is unset */ +$unset_obj = new object_class(); +unset($unset_obj); + +$objects = array ( + new object_class, + new no_member_class, + new contains_object_class, + $obj, + $obj->class_object1, + $obj->class_object2, + $obj->no_member_class_object, + $temp_class_obj, + @$unset_obj +); +/* calling check_vardump() to display contents of the objects + using var_dump() */ +check_vardump($objects); + +echo "\n** Testing var_dump() on objects having circular reference **\n"; +$recursion_obj1 = new object_class(); +$recursion_obj2 = new object_class(); +$recursion_obj1->obj = &$recursion_obj2; //circular reference +$recursion_obj2->obj = &$recursion_obj1; //circular reference +var_dump($recursion_obj2); + +echo "\n*** Testing var_dump() on resources ***\n"; +/* file type resource */ +$file_handle = fopen(__FILE__, "r"); + +/* directory type resource */ +$dir_handle = opendir( dirname(__FILE__) ); + +$resources = array ( + $file_handle, + $dir_handle +); +/* calling check_vardump() to display the resource content type + using var_dump() */ +check_vardump($resources); + +echo "\n*** Testing var_dump() on different combinations of scalar + and non-scalar variables ***\n"; +/* a variable which is unset */ +$unset_var = 10.5; +unset($unset_var); + +/* unset file type resource */ +unset($file_handle); + +$variations = array ( + array( 123, -1.2345, "a" ), + array( "d", array(1, 3, 5), true, null), + array( new no_member_class, array(), false, 0 ), + array( -0.00, "Where am I?", array(7,8,9), TRUE, 'A', 987654321 ), + array( @$unset_var, 2.E+10, 100-20.9, 000004.599998 ), //unusual data + array( "array(1,2,3,4)1.0000002TRUE", @$file_handle, 111333.00+45e5, '/00\7') +); +/* calling check_vardump() to display combinations of scalar and + non-scalar variables using var_dump() */ +check_vardump($variations); + +echo "\n*** Testing var_dump() on miscelleneous input arguments ***\n"; +$misc_values = array ( + @$unset_var, + NULL, // NULL argument + @$undef_variable, //undefined variable + null +); +/* calling check_vardump() to display miscelleneous data using var_dump() */ +check_vardump($misc_values); + +echo "\n*** Testing var_dump() on multiple arguments ***\n"; +var_dump( $integers, $floats, $strings, $arrays, $booleans, $resources, + $objects, $misc_values, $variations ); + +/* checking var_dump() on functions */ +echo "\n*** Testing var_dump() on anonymous functions ***\n"; +$newfunc = create_function('$a,$b', 'return "$a * $b = " . ($a * $b);'); +echo "New anonymous function: $newfunc\n"; +var_dump( $newfunc(2, 3) ); +/* creating anonymous function dynamically */ +var_dump( create_function('$a', 'return "$a * $a = " . ($a * $b);') ); + +echo "\n*** Testing error conditions ***\n"; +//passing zero argument +var_dump(); + +/* closing resource handle used */ +closedir($dir_handle); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing var_dump() on integer variables *** +-- Iteration 1 -- +int(0) +-- Iteration 2 -- +int(83) +-- Iteration 3 -- +int(123000000) +-- Iteration 4 -- +int(-83) +-- Iteration 5 -- +int(-12300000) +-- Iteration 6 -- +array(10) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + [6]=> + int(7) + [7]=> + int(8) + [8]=> + int(9) + [9]=> + int(10) +} +-- Iteration 7 -- +array(10) { + [0]=> + int(-1) + [1]=> + int(-2) + [2]=> + int(-3) + [3]=> + int(-4) + [4]=> + int(-5) + [5]=> + int(-6) + [6]=> + int(-7) + [7]=> + int(-8) + [8]=> + int(-9) + [9]=> + int(-10) +} +-- Iteration 8 -- +int(2147483647) +-- Iteration 9 -- +float(2147483648) +-- Iteration 10 -- +float(-2147483648) +-- Iteration 11 -- +int(-2147483647) +-- Iteration 12 -- +int(2147483647) +-- Iteration 13 -- +float(-2147483648) +-- Iteration 14 -- +int(2147483647) +-- Iteration 15 -- +float(-2147483648) + +*** Testing var_dump() on float variables *** +-- Iteration 1 -- +float(0) +-- Iteration 2 -- +float(0) +-- Iteration 3 -- +float(1.234) +-- Iteration 4 -- +float(-1.234) +-- Iteration 5 -- +float(-2) +-- Iteration 6 -- +float(2) +-- Iteration 7 -- +float(-0.5) +-- Iteration 8 -- +float(0.567) +-- Iteration 9 -- +float(-0.00067) +-- Iteration 10 -- +float(-670) +-- Iteration 11 -- +float(670) +-- Iteration 12 -- +float(670) +-- Iteration 13 -- +float(-0.00410003) +-- Iteration 14 -- +float(-4100.03) +-- Iteration 15 -- +float(0.004100003) +-- Iteration 16 -- +float(4100.003) +-- Iteration 17 -- +float(100000) +-- Iteration 18 -- +float(-100000) +-- Iteration 19 -- +float(1.0E-5) +-- Iteration 20 -- +float(-1.0E-5) +-- Iteration 21 -- +float(100000) +-- Iteration 22 -- +float(-100000) +-- Iteration 23 -- +float(100000) +-- Iteration 24 -- +float(-100000) +-- Iteration 25 -- +float(100000) +-- Iteration 26 -- +float(-100000) +-- Iteration 27 -- +float(1.0E-5) +-- Iteration 28 -- +float(-1.0E-5) +-- Iteration 29 -- +float(-2147483649) +-- Iteration 30 -- +float(2147483649) +-- Iteration 31 -- +float(2147483649) +-- Iteration 32 -- +float(-2147483649) + +*** Testing var_dump() on string variables *** +-- Iteration 1 -- +string(0) "" +-- Iteration 2 -- +string(0) "" +-- Iteration 3 -- +string(1) " " +-- Iteration 4 -- +string(1) " " +-- Iteration 5 -- +string(1) "0" +-- Iteration 6 -- +string(1) "+-- Iteration 7 -- +string(2) "\0" +-- Iteration 8 -- +string(1) " " +-- Iteration 9 -- +string(2) "\t" +-- Iteration 10 -- +string(3) "PHP" +-- Iteration 11 -- +string(3) "PHP" +-- Iteration 12 -- +string(29) "abcd+-- Iteration 13 -- +string(34) "abcd+-- Iteration 14 -- +string(22) "1234 +5678 + 9100abcda" + +*** Testing var_dump() on boolean variables *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(false) + +*** Testing var_dump() on array variables *** +-- Iteration 1 -- +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + NULL +} +-- Iteration 3 -- +array(1) { + [0]=> + NULL +} +-- Iteration 4 -- +array(1) { + [0]=> + bool(true) +} +-- Iteration 5 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 6 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 7 -- +array(2) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } +} +-- Iteration 8 -- +array(2) { + [0]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [1]=> + array(2) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + } +} +-- Iteration 9 -- +array(1) { + [1]=> + string(3) "One" +} +-- Iteration 10 -- +array(1) { + ["test"]=> + string(8) "is_array" +} +-- Iteration 11 -- +array(1) { + [0]=> + int(0) +} +-- Iteration 12 -- +array(1) { + [0]=> + int(-1) +} +-- Iteration 13 -- +array(2) { + [0]=> + float(10.5) + [1]=> + float(5.6) +} +-- Iteration 14 -- +array(2) { + [0]=> + string(6) "string" + [1]=> + string(4) "test" +} +-- Iteration 15 -- +array(2) { + [0]=> + string(6) "string" + [1]=> + string(4) "test" +} +-- Iteration 16 -- +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + *RECURSION* + } + } +} + +*** Testing var_dump() on object variables *** +-- Iteration 1 -- +object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) +} +-- Iteration 2 -- +object(no_member_class)#%d (0) { +} +-- Iteration 3 -- +object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + *RECURSION* + } +} +-- Iteration 4 -- +object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + *RECURSION* + } +} +-- Iteration 5 -- +object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) +} +-- Iteration 6 -- +object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) +} +-- Iteration 7 -- +object(no_member_class)#%d (0) { +} +-- Iteration 8 -- +object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) +} +-- Iteration 9 -- +NULL + +** Testing var_dump() on objects having circular reference ** +object(object_class)#%d (8) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + ["obj"]=> + &object(object_class)#%d (8) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + ["obj"]=> + &object(object_class)#%d (8) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + ["obj"]=> + &object(object_class)#%d (8) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + ["obj"]=> + *RECURSION* + } + } + } +} + +*** Testing var_dump() on resources *** +-- Iteration 1 -- +resource(%d) of type (stream) +-- Iteration 2 -- +resource(%d) of type (stream) + +*** Testing var_dump() on different combinations of scalar + and non-scalar variables *** +-- Iteration 1 -- +array(3) { + [0]=> + int(123) + [1]=> + float(-1.2345) + [2]=> + string(1) "a" +} +-- Iteration 2 -- +array(4) { + [0]=> + string(1) "d" + [1]=> + array(3) { + [0]=> + int(1) + [1]=> + int(3) + [2]=> + int(5) + } + [2]=> + bool(true) + [3]=> + NULL +} +-- Iteration 3 -- +array(4) { + [0]=> + object(no_member_class)#%d (0) { + } + [1]=> + array(0) { + } + [2]=> + bool(false) + [3]=> + int(0) +} +-- Iteration 4 -- +array(6) { + [0]=> + float(0) + [1]=> + string(11) "Where am I?" + [2]=> + array(3) { + [0]=> + int(7) + [1]=> + int(8) + [2]=> + int(9) + } + [3]=> + bool(true) + [4]=> + string(1) "A" + [5]=> + int(987654321) +} +-- Iteration 5 -- +array(4) { + [0]=> + NULL + [1]=> + float(20000000000) + [2]=> + float(79.1) + [3]=> + float(4.599998) +} +-- Iteration 6 -- +array(4) { + [0]=> + string(27) "array(1,2,3,4)1.0000002TRUE" + [1]=> + NULL + [2]=> + float(4611333) + [3]=> + string(5) "/00\7" +} + +*** Testing var_dump() on miscelleneous input arguments *** +-- Iteration 1 -- +NULL +-- Iteration 2 -- +NULL +-- Iteration 3 -- +NULL +-- Iteration 4 -- +NULL + +*** Testing var_dump() on multiple arguments *** +array(15) { + [0]=> + int(0) + [1]=> + int(83) + [2]=> + int(123000000) + [3]=> + int(-83) + [4]=> + int(-12300000) + [5]=> + array(10) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + [6]=> + int(7) + [7]=> + int(8) + [8]=> + int(9) + [9]=> + int(10) + } + [6]=> + array(10) { + [0]=> + int(-1) + [1]=> + int(-2) + [2]=> + int(-3) + [3]=> + int(-4) + [4]=> + int(-5) + [5]=> + int(-6) + [6]=> + int(-7) + [7]=> + int(-8) + [8]=> + int(-9) + [9]=> + int(-10) + } + [7]=> + int(2147483647) + [8]=> + float(2147483648) + [9]=> + float(-2147483648) + [10]=> + int(-2147483647) + [11]=> + int(2147483647) + [12]=> + float(-2147483648) + [13]=> + int(2147483647) + [14]=> + float(-2147483648) +} +array(32) { + [0]=> + float(0) + [1]=> + float(0) + [2]=> + float(1.234) + [3]=> + float(-1.234) + [4]=> + float(-2) + [5]=> + float(2) + [6]=> + float(-0.5) + [7]=> + float(0.567) + [8]=> + float(-0.00067) + [9]=> + float(-670) + [10]=> + float(670) + [11]=> + float(670) + [12]=> + float(-0.00410003) + [13]=> + float(-4100.03) + [14]=> + float(0.004100003) + [15]=> + float(4100.003) + [16]=> + float(100000) + [17]=> + float(-100000) + [18]=> + float(1.0E-5) + [19]=> + float(-1.0E-5) + [20]=> + float(100000) + [21]=> + float(-100000) + [22]=> + float(100000) + [23]=> + float(-100000) + [24]=> + float(100000) + [25]=> + float(-100000) + [26]=> + float(1.0E-5) + [27]=> + float(-1.0E-5) + [28]=> + float(-2147483649) + [29]=> + float(2147483649) + [30]=> + float(2147483649) + [31]=> + float(-2147483649) +} +array(14) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(1) " " + [3]=> + string(1) " " + [4]=> + string(1) "0" + [5]=> + string(1) "+ [6]=> + string(2) "\0" + [7]=> + string(1) " " + [8]=> + string(2) "\t" + [9]=> + string(3) "PHP" + [10]=> + string(3) "PHP" + [11]=> + string(29) "abcd+ [12]=> + string(34) "abcd+ [13]=> + string(22) "1234 +5678 + 9100abcda" +} +array(16) { + [0]=> + array(0) { + } + [1]=> + array(1) { + [0]=> + NULL + } + [2]=> + array(1) { + [0]=> + NULL + } + [3]=> + array(1) { + [0]=> + bool(true) + } + [4]=> + array(1) { + [0]=> + string(0) "" + } + [5]=> + array(1) { + [0]=> + string(0) "" + } + [6]=> + array(2) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } + } + [7]=> + array(2) { + [0]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [1]=> + array(2) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + } + } + [8]=> + array(1) { + [1]=> + string(3) "One" + } + [9]=> + array(1) { + ["test"]=> + string(8) "is_array" + } + [10]=> + array(1) { + [0]=> + int(0) + } + [11]=> + array(1) { + [0]=> + int(-1) + } + [12]=> + array(2) { + [0]=> + float(10.5) + [1]=> + float(5.6) + } + [13]=> + array(2) { + [0]=> + string(6) "string" + [1]=> + string(4) "test" + } + [14]=> + array(2) { + [0]=> + string(6) "string" + [1]=> + string(4) "test" + } + [15]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + *RECURSION* + } + } + } +} +array(4) { + [0]=> + bool(true) + [1]=> + bool(false) + [2]=> + bool(true) + [3]=> + bool(false) +} +array(2) { + [0]=> + resource(%d) of type (stream) + [1]=> + resource(%d) of type (stream) +} +array(9) { + [0]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + [1]=> + object(no_member_class)#%d (0) { + } + [2]=> + object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + *RECURSION* + } + } + [3]=> + object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + object(contains_object_class)#%d (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#%d (0) { + } + ["class_object5"]=> + *RECURSION* + } + } + [4]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + [5]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + [6]=> + object(no_member_class)#%d (0) { + } + [7]=> + object(object_class)#%d (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + [8]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL +} +array(6) { + [0]=> + array(3) { + [0]=> + int(123) + [1]=> + float(-1.2345) + [2]=> + string(1) "a" + } + [1]=> + array(4) { + [0]=> + string(1) "d" + [1]=> + array(3) { + [0]=> + int(1) + [1]=> + int(3) + [2]=> + int(5) + } + [2]=> + bool(true) + [3]=> + NULL + } + [2]=> + array(4) { + [0]=> + object(no_member_class)#%d (0) { + } + [1]=> + array(0) { + } + [2]=> + bool(false) + [3]=> + int(0) + } + [3]=> + array(6) { + [0]=> + float(0) + [1]=> + string(11) "Where am I?" + [2]=> + array(3) { + [0]=> + int(7) + [1]=> + int(8) + [2]=> + int(9) + } + [3]=> + bool(true) + [4]=> + string(1) "A" + [5]=> + int(987654321) + } + [4]=> + array(4) { + [0]=> + NULL + [1]=> + float(20000000000) + [2]=> + float(79.1) + [3]=> + float(4.599998) + } + [5]=> + array(4) { + [0]=> + string(27) "array(1,2,3,4)1.0000002TRUE" + [1]=> + NULL + [2]=> + float(4611333) + [3]=> + string(5) "/00\7" + } +} + +*** Testing var_dump() on anonymous functions *** +New anonymous function: +string(9) "2 * 3 = 6" +string(9) "+ +*** Testing error conditions *** + +Warning: Wrong parameter count for var_dump() in %s on line %d +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/debug_zval_dump_e.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/debug_zval_dump_e.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/debug_zval_dump_e.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/debug_zval_dump_e.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,23 @@ +--TEST-- +Test debug_zval_dump() function : error conditions +--FILE-- +<?php +/* Prototype: void debug_zval_dump ( mixed $variable ); + Description: Dumps a string representation of an internal zend value + to output. +*/ + +echo "*** Testing error conditions ***\n"; + +/* passing zero argument */ +debug_zval_dump(); + +echo "Done\n"; + +?> + +--EXPECTF-- +*** Testing error conditions *** + +Warning: Wrong parameter count for debug_zval_dump() in %s on line %d +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/debug_zval_dump_v.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/debug_zval_dump_v.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/debug_zval_dump_v.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/debug_zval_dump_v.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,214 @@ +--TEST-- +Test debug_zval_dump() function : usage variations +--FILE-- +<?php +/* Prototype: void debug_zval_dump ( mixed $variable ); + Description: Dumps a string representation of an internal zend value + to output. +*/ + +echo "*** Testing debug_zval_dump() on functions ***\n"; +echo "--- Variation 1: global variable inside a function ---\n"; +$global_var = 10; //declaring global variable + +/* function to dump reference count of global variable,$global_var + and local variable,$local_var */ +function dump_globalvar( &$local_var ) { + global $global_var; + echo "\n-- Value of local variable inside dump_globalvar() --\n"; + debug_zval_dump( $local_var ); + echo "\n-- Value of global variable inside dump_globalvar() --\n"; + debug_zval_dump( $global_var ); +} +/* dump value and reference count of $global_var using debug_zval_dump() */ +echo "\n-- Value of global variable, before calling dump_globalvar() --\n"; +debug_zval_dump( $global_var ); + +/* calling function dump_globalvar() to check the reference count of local + and global variables inside the function */ +dump_globalvar( $global_var ); + +/* dump value and reference count of $global_var after exiting function + dump_globalvar(); + expected: reference count of $global_var should remain the same as + before calling dump_globalvar() function */ +echo "\n-- Value of global variable, after exiting dump_globalvar() --\n"; +debug_zval_dump( $global_var ); + +echo "\n--- Variation 2: one variable references another ---\n"; +$first_var = 10; +/* dump value and reference count of $first_var */ +echo "\n-- Value of \$first_var: --\n"; +debug_zval_dump($first_var); + +/* $ref_first_var references $first_var */ +$ref_first_var = &$var_1; + +echo "\n-- Value of \$ref_first_var --\n"; +debug_zval_dump($ref_first_var); +echo "\n-- Value of \$first_var --\n"; +debug_zval_dump($first_var); + +unset($ref_first_var); + +/* dump value and reference count of $first_var, $ref_first_var + here $ref_first_var is unset */ +echo "\n-- Value of \$ref_first_var --\n"; +debug_zval_dump($ref_first_var); +echo "\n-- Value of \$first_var --\n"; +debug_zval_dump($first_var); + +echo "\n--- Variation 3: multiple references of variables ---\n"; +$var_1 = 10; +$var_2 = &$var_1; +$var_3 = &$var_2; +echo "\n-- Value of \$var_1: (before referencing) --\n"; +debug_zval_dump($var_1); +echo "\n-- Value of \$var_2: (referencing var_1) --\n"; +debug_zval_dump($var_2); +echo "\n-- Value of \$var_3: (referencing var_2) --\n"; +debug_zval_dump($var_3); + +/* unsetting $var_3 */ +unset($var_3); +echo "\n-- Value of \$var_3: (after unsetting var_3) --\n"; +debug_zval_dump($var_3); +echo "\n-- Value of \$var_2: --\n"; +debug_zval_dump($var_2); +echo "\n-- Value of \$var_3: --\n"; +debug_zval_dump($var_1); + +/* unsetting $var_1 */ +unset($var_1); +echo "\n-- Value of \$var_1: (after unsetting variable_1) --\n"; +debug_zval_dump($var_1); +echo "\n-- Value of \$var_2: --\n"; +debug_zval_dump($var_2); + +echo "\n*** Testing debug_zval_dump() on miscelleneous input arguments ***\n"; +/* unset a variable */ +$unset_var = 10.5; +unset($unset_var); + +$misc_values = array ( + /* nulls */ + NULL, + null, + + /* unset variable */ + @$unset_var, + + /* undefined variable */ + @$undef_var, + + /* mixed types */ + @TRUE123, + "123string", + "string123", + "NULLstring" +); +/* loop to display the variables and its reference count using + debug_zval_dump() */ +$counter = 1; +foreach( $misc_values as $value ) { + echo "-- Iteration $counter --\n"; + debug_zval_dump( $value ); + debug_zval_dump( &$value ); + $counter++; +} + +echo "Done\n"; +?> + +--EXPECTF-- +Strict Standards: Call-time pass-by-reference has been deprecated in %s on line %d +*** Testing debug_zval_dump() on functions *** +--- Variation 1: global variable inside a function --- + +-- Value of global variable, before calling dump_globalvar() -- +long(10) refcount(2) + +-- Value of local variable inside dump_globalvar() -- +long(10) refcount(1) + +-- Value of global variable inside dump_globalvar() -- +long(10) refcount(1) + +-- Value of global variable, after exiting dump_globalvar() -- +long(10) refcount(2) + +--- Variation 2: one variable references another --- + +-- Value of $first_var: -- +long(10) refcount(2) + +-- Value of $ref_first_var -- +NULL refcount(1) + +-- Value of $first_var -- +long(10) refcount(2) + +-- Value of $ref_first_var -- + +Notice: Undefined variable: ref_first_var in %s on line %d +NULL refcount(1) + +-- Value of $first_var -- +long(10) refcount(2) + +--- Variation 3: multiple references of variables --- + +-- Value of $var_1: (before referencing) -- +long(10) refcount(1) + +-- Value of $var_2: (referencing var_1) -- +long(10) refcount(1) + +-- Value of $var_3: (referencing var_2) -- +long(10) refcount(1) + +-- Value of $var_3: (after unsetting var_3) -- + +Notice: Undefined variable: var_3 in %s on line %d +NULL refcount(1) + +-- Value of $var_2: -- +long(10) refcount(1) + +-- Value of $var_3: -- +long(10) refcount(1) + +-- Value of $var_1: (after unsetting variable_1) -- + +Notice: Undefined variable: var_1 in %s on line %d +NULL refcount(1) + +-- Value of $var_2: -- +long(10) refcount(2) + +*** Testing debug_zval_dump() on miscelleneous input arguments *** +-- Iteration 1 -- +NULL refcount(3) +&NULL refcount(2) +-- Iteration 2 -- +NULL refcount(3) +&NULL refcount(2) +-- Iteration 3 -- +NULL refcount(1) +&NULL refcount(2) +-- Iteration 4 -- +NULL refcount(1) +&NULL refcount(2) +-- Iteration 5 -- +string(7) "TRUE123" refcount(3) +&string(7) "TRUE123" refcount(2) +-- Iteration 6 -- +string(9) "123string" refcount(3) +&string(9) "123string" refcount(2) +-- Iteration 7 -- +string(9) "string123" refcount(3) +&string(9) "string123" refcount(2) +-- Iteration 8 -- +string(10) "NULLstring" refcount(3) +&string(10) "NULLstring" refcount(2) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_bool.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_bool.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_bool.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_bool.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,296 @@ +--TEST-- +Test is_bool() function +--FILE-- +<?php +/* Prototype: bool is_bool ( mixed $var ); + * Description: Finds whether the given variable is a boolean + */ + +echo "*** Testing is_bool() with valid boolean values ***\n"; +// different valid boolean vlaues +$valid_bools = array( + TRUE, + FALSE, + true, + false, +); +/* loop to check that is_bool() recognizes different + bool values, expected output: bool(true) */ +$loop_counter = 1; +foreach ($valid_bools as $bool_val ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_bool($bool_val) ); +} + +echo "\n*** Testing is_bool() on non boolean values ***\n"; + +// get a resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); + +// unset variable +$unset_bool1 = true; +$unset_bool2 = false; +$unset_var = 0; +unset ($unset_bool1); +unset ($unset_bool2); +unset ($unset_var); + +// other types in a array +$not_bool_types = array ( + /* integers */ + 0, + 1, + -1, + -0, + 543915, + -5322, + 0x0, + 0x1, + 0x55F, + -0xCCF, + 0123, + -0654, + 00, + 01, + + /* strings */ + "", + '', + "0", + '0', + "1", + '1', + 'string', + "string", + "true", + "false", + "FALSE", + "TRUE", + 'true', + 'false', + 'FALSE', + 'TRUE', + "NULL", + "null", + + /* floats */ + 0.0, + 1.0, + -1.0, + 10.0000000000000000005, + .5e6, + -.5E7, + .5E+8, + -.5e+90, + 1e5, + -1e5, + 1E5, + -1E7, + + /* objects */ + new stdclass, + + /* resources */ + $fp, + $dfp, + + /* nulls */ + null, + NULL, + + /* arrays */ + array(), + array(0), + array(1), + array(NULL), + array(null), + array("string"), + array(true), + array(TRUE), + array(false), + array(FALSE), + array(1,2,3,4), + array(1 => "One", "two" => 2), + + /* unset bool vars and undefined var */ + @$unset_bool1, + @$unset_bool2, + @$unset_var, + @$undefined_var +); +/* loop through the $not_bool_types to see working of + is_bool() on non bull types, expected output: bool(false) */ +$loop_counter = 1; +foreach ($not_bool_types as $type ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_bool($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_bool() ); + +//arguments more than expected +var_dump( is_bool(TRUE, FALSE) ); + +echo "Done\n"; +?> + +--CLEAN-- +// close resources +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_bool() with valid boolean values *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +*** Testing is_bool() on non boolean values *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +-- Iteration 27 -- +bool(false) +-- Iteration 28 -- +bool(false) +-- Iteration 29 -- +bool(false) +-- Iteration 30 -- +bool(false) +-- Iteration 31 -- +bool(false) +-- Iteration 32 -- +bool(false) +-- Iteration 33 -- +bool(false) +-- Iteration 34 -- +bool(false) +-- Iteration 35 -- +bool(false) +-- Iteration 36 -- +bool(false) +-- Iteration 37 -- +bool(false) +-- Iteration 38 -- +bool(false) +-- Iteration 39 -- +bool(false) +-- Iteration 40 -- +bool(false) +-- Iteration 41 -- +bool(false) +-- Iteration 42 -- +bool(false) +-- Iteration 43 -- +bool(false) +-- Iteration 44 -- +bool(false) +-- Iteration 45 -- +bool(false) +-- Iteration 46 -- +bool(false) +-- Iteration 47 -- +bool(false) +-- Iteration 48 -- +bool(false) +-- Iteration 49 -- +bool(false) +-- Iteration 50 -- +bool(false) +-- Iteration 51 -- +bool(false) +-- Iteration 52 -- +bool(false) +-- Iteration 53 -- +bool(false) +-- Iteration 54 -- +bool(false) +-- Iteration 55 -- +bool(false) +-- Iteration 56 -- +bool(false) +-- Iteration 57 -- +bool(false) +-- Iteration 58 -- +bool(false) +-- Iteration 59 -- +bool(false) +-- Iteration 60 -- +bool(false) +-- Iteration 61 -- +bool(false) +-- Iteration 62 -- +bool(false) +-- Iteration 63 -- +bool(false) +-- Iteration 64 -- +bool(false) +-- Iteration 65 -- +bool(false) + +*** Testing error conditions *** + +Warning: is_bool() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_bool() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/strval.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/strval.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/strval.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/strval.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,308 @@ +--TEST-- +Test strval() function +--FILE-- +<?php +/* Prototype: string strval ( mixed $var ); + * Description: Returns the string value of var + */ + +echo "*** Testing str_val() with scalar values***\n"; +$heredoc_string = <<<EOD +This is a multiline heredoc +string. Numeric = 1232455. +EOD; +/* heredoc string with only numeric values */ +$heredoc_numeric_string = <<<EOD +12345 +2345 +EOD; +/* null heredoc string */ +$heredoc_empty_string = <<<EOD +EOD; +/* heredoc string with NULL */ +$heredoc_NULL_string = <<<EOD +NULL +EOD; + +// different valid scalar vlaues +$scalars = array( + /* integers */ + 0, + 1, + -1, + -2147483648, // max negative integer value + -2147483647, + 2147483647, // max positive integer value + 2147483640, + 0x123B, // integer as hexadecimal + 0x12ab, + 0Xfff, + 0XFA, + + /* floats */ + -0x80000000, // max negative integer as hexadecimal + 0x7fffffff, // max postive integer as hexadecimal + 0x7FFFFFFF, // max postive integer as hexadecimal + 0123, // integer as octal + 01912, // should be quivalent to octal 1 + -020000000000, // max negative integer as octal + 017777777777, // max positive integer as octal + -2147483649, // float value + 2147483648, // float value + -0x80000001, // float value, beyond max negative int + 0x800000001, // float value, beyond max positive int + 020000000001, // float value, beyond max positive int + -020000000001, // float value, beyond max negative int + 0.0, + -0.1, + 10.0000000000000000005, + 10.5e+5, + 1e-5, + .5e+7, + .6e-19, + .05E+44, + .0034E-30, + + /* booleans */ + true, + TRUE, + FALSE, + false, + + /* strings */ + "", + '', + " ", + ' ', + '0', + "0", + "testing", + "0x564", + "0123", + "new\n", + 'new\n', + "@#$$%^&&*()", + " ", + "null", + 'null', + 'true', + "true", + /*"\0123", + "\0x12FF",*/ + $heredoc_string, + $heredoc_numeric_string, + $heredoc_empty_string +); +/* loop to check that strval() recognizes different + scalar values and retuns the string conversion of same */ +$loop_counter = 1; +foreach ($scalars as $scalar ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( strval($scalar) ); +} + +echo "\n*** Testing strval() with non_scalar values ***\n"; +// get a resource type variable +$fp = fopen(__FILE__, "r"); +$dfp = opendir( dirname(__FILE__) ); + +// unset variable +$unset_var = 10; +unset ($unset_var); + +// non_scalar values, objects, arrays, resources and boolean +class foo +{ + function __toString() { + return "Object"; + } +} + +$not_scalars = array ( + new foo, //object + $fp, // resource + $dfp, + array(), // arrays + array(NULL), + array(1,2,3,4), + array("string"), + NULL, // nulls + null, + @$unset_var, // unset variable + @$undefined_var +); +/* loop through the $not_scalars to see working of + strval() on objects, arrays, boolean and others */ +$loop_counter = 1; +foreach ($not_scalars as $value ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( strval($value) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( strval() ); + +//arguments more than expected +var_dump( strval( $scalars[0], $scalars[1]) ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources used +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing str_val() with scalar values*** +-- Iteration 1 -- +string(1) "0" +-- Iteration 2 -- +string(1) "1" +-- Iteration 3 -- +string(2) "-1" +-- Iteration 4 -- +string(11) "-2147483648" +-- Iteration 5 -- +string(11) "-2147483647" +-- Iteration 6 -- +string(10) "2147483647" +-- Iteration 7 -- +string(10) "2147483640" +-- Iteration 8 -- +string(4) "4667" +-- Iteration 9 -- +string(4) "4779" +-- Iteration 10 -- +string(4) "4095" +-- Iteration 11 -- +string(3) "250" +-- Iteration 12 -- +string(11) "-2147483648" +-- Iteration 13 -- +string(10) "2147483647" +-- Iteration 14 -- +string(10) "2147483647" +-- Iteration 15 -- +string(2) "83" +-- Iteration 16 -- +string(1) "1" +-- Iteration 17 -- +string(11) "-2147483648" +-- Iteration 18 -- +string(10) "2147483647" +-- Iteration 19 -- +string(11) "-2147483649" +-- Iteration 20 -- +string(10) "2147483648" +-- Iteration 21 -- +string(11) "-2147483649" +-- Iteration 22 -- +string(11) "34359738369" +-- Iteration 23 -- +string(10) "2147483649" +-- Iteration 24 -- +string(11) "-2147483649" +-- Iteration 25 -- +string(1) "0" +-- Iteration 26 -- +string(4) "-0.1" +-- Iteration 27 -- +string(2) "10" +-- Iteration 28 -- +string(7) "1050000" +-- Iteration 29 -- +string(6) "1.0E-5" +-- Iteration 30 -- +string(7) "5000000" +-- Iteration 31 -- +string(7) "6.0E-20" +-- Iteration 32 -- +string(7) "5.0E+42" +-- Iteration 33 -- +string(7) "3.4E-33" +-- Iteration 34 -- +string(1) "1" +-- Iteration 35 -- +string(1) "1" +-- Iteration 36 -- +string(0) "" +-- Iteration 37 -- +string(0) "" +-- Iteration 38 -- +string(0) "" +-- Iteration 39 -- +string(0) "" +-- Iteration 40 -- +string(1) " " +-- Iteration 41 -- +string(1) " " +-- Iteration 42 -- +string(1) "0" +-- Iteration 43 -- +string(1) "0" +-- Iteration 44 -- +string(7) "testing" +-- Iteration 45 -- +string(5) "0x564" +-- Iteration 46 -- +string(4) "0123" +-- Iteration 47 -- +string(4) "new +" +-- Iteration 48 -- +string(5) "new\n" +-- Iteration 49 -- +string(11) "@#$$%^&&*()" +-- Iteration 50 -- +string(8) " " +-- Iteration 51 -- +string(4) "null" +-- Iteration 52 -- +string(4) "null" +-- Iteration 53 -- +string(4) "true" +-- Iteration 54 -- +string(4) "true" +-- Iteration 55 -- +string(54) "This is a multiline heredoc +string. Numeric = 1232455." +-- Iteration 56 -- +string(10) "12345 +2345" +-- Iteration 57 -- +string(0) "" + +*** Testing strval() with non_scalar values *** +-- Iteration 1 -- +string(6) "Object" +-- Iteration 2 -- +string(14) "Resource id #5" +-- Iteration 3 -- +string(14) "Resource id #6" +-- Iteration 4 -- +string(5) "Array" +-- Iteration 5 -- +string(5) "Array" +-- Iteration 6 -- +string(5) "Array" +-- Iteration 7 -- +string(5) "Array" +-- Iteration 8 -- +string(0) "" +-- Iteration 9 -- +string(0) "" +-- Iteration 10 -- +string(0) "" +-- Iteration 11 -- +string(0) "" + +*** Testing error conditions *** + +Warning: Wrong parameter count for strval() in %s on line %d +NULL + +Warning: Wrong parameter count for strval() in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_array.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_array.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_array.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_array.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,215 @@ +--TEST-- +Test is_array() function +--FILE-- +<?php +/* Prototype: bool is_array ( mixed $var ); + * Description: Finds whether the given variable is an array + */ + +echo "*** Testing is_array() on different type of arrays ***\n"; +/* different types of arrays */ +$arrays = array( + array(), + array(NULL), + array(null), + array(true), + array(""), + array(''), + array(array(), array()), + array(array(1, 2), array('a', 'b')), + array(1 => 'One'), + array("test" => "is_array"), + array(0), + array(-1), + array(10.5, 5.6), + array("string", "test"), + array('string', 'test') +); +/* loop to check that is_array() recognizes different + type of arrays, expected output bool(true) */ +$loop_counter = 1; +foreach ($arrays as $var_array ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_array ($var_array) ); +} + +echo "\n*** Testing is_array() on non array types ***\n"; + +// get a resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); + +// unset variables +$unset_array = array(10); +unset($unset_array); + +// other types in a array +$varient_arrays = array ( + /* integers */ + 543915, + -5322, + 0x55F, + -0xCCF, + 123, + -0654, + + /* strings */ + "", + '', + "0", + '0', + 'string', + "string", + + /* floats */ + 10.0000000000000000005, + .5e6, + -.5E7, + .5E+8, + -.5e+90, + 1e5, + + /* objects */ + new stdclass, + + /* resources */ + $fp, + $dfp, + + /* nulls */ + null, + NULL, + + /* boolean */ + true, + TRUE, + FALSE, + false, + + /* unset/undefined arrays */ + @$unset_array, + @$undefined_array +); +/* loop through the $varient_array to see working of + is_array() on non array types, expected output bool(false) */ +$loop_counter = 1; +foreach ($varient_arrays as $type ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_array ($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_array() ); + +//arguments more than expected +var_dump( is_array ($fp, $fp) ); + +echo "Done\n"; +?> +--CLEAN-- +/* close resources */ +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_array() on different type of arrays *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) +-- Iteration 11 -- +bool(true) +-- Iteration 12 -- +bool(true) +-- Iteration 13 -- +bool(true) +-- Iteration 14 -- +bool(true) +-- Iteration 15 -- +bool(true) + +*** Testing is_array() on non array types *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +-- Iteration 27 -- +bool(false) +-- Iteration 28 -- +bool(false) +-- Iteration 29 -- +bool(false) + +*** Testing error conditions *** + +Warning: is_array() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_array() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_null.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_null.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_null.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_null.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,298 @@ +--TEST-- +Test is_null() function +--FILE-- +<?php +/* Prototype: bool is_null ( mixed $var ); + * Description: Finds whether the given variable is NULL + */ + +echo "*** Testing is_null() with valid null values ***\n"; +// different valid null vlaues +$unset_array = array(); +$unset_int = 10; +$unset_float = 10.5; +$unset_bool = true; +$unset_object = new stdclass; +$unset_resource = fopen(__FILE__, "r"); +// unset them to make it null. +unset ($unset_array, $unset_int, $unset_float, $unset_bool, $unset_object, $unset_resource); +$null_var1 = NULL; +$null_var2 = null; + +$valid_nulls = array( + NULL, + null, + @$null_var1, + @$null_var2, + @$unset_array, + @$unset_int, + @$unset_float, + @$unset_bool, + @$unset_object, + @$unset_resource, + @$undefined_var, +); +/* loop to check that is_null() recognizes different + null values, expected output: bool(true) */ +$loop_counter = 1; +foreach ($valid_nulls as $null_val ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_null($null_val) ); +} + +echo "\n*** Testing is_bool() on non null values ***\n"; + +// get a resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); + +// other types in a array +$not_null_types = array ( +/* integers */ + 0, + 1, + -1, + -0, + 543915, + -5322, + 0x0, + 0x1, + 0x55F, + -0xCCF, + 0123, + -0654, + 00, + 01, + + /* strings */ + "", + '', + "0", + '0', + "1", + '1', + 'string', + "string", + "true", + "false", + "FALSE", + "TRUE", + 'true', + 'false', + 'FALSE', + 'TRUE', + "NULL", + "null", + + /* floats */ + 0.0, + 1.0, + -1.0, + 10.0000000000000000005, + .5e6, + -.5E7, + .5E+8, + -.5e+90, + 1e5, + -1e5, + 1E5, + -1E7, + + /* objects */ + new stdclass, + + /* resources */ + $fp, + $dfp, + + /* arrays */ + array(), + array(0), + array(1), + array(NULL), + array(null), + array("string"), + array(true), + array(TRUE), + array(false), + array(FALSE), + array(1,2,3,4), + array(1 => "One", "two" => 2), +); +/* loop through the $not_null_types to see working of + is_null() on non null types, expected output: bool(false) */ +$loop_counter = 1; +foreach ($not_null_types as $type ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_null($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_null() ); + +//arguments more than expected +var_dump( is_null(NULL, null) ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources used +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_null() with valid null values *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) +-- Iteration 11 -- +bool(true) + +*** Testing is_bool() on non null values *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +-- Iteration 27 -- +bool(false) +-- Iteration 28 -- +bool(false) +-- Iteration 29 -- +bool(false) +-- Iteration 30 -- +bool(false) +-- Iteration 31 -- +bool(false) +-- Iteration 32 -- +bool(false) +-- Iteration 33 -- +bool(false) +-- Iteration 34 -- +bool(false) +-- Iteration 35 -- +bool(false) +-- Iteration 36 -- +bool(false) +-- Iteration 37 -- +bool(false) +-- Iteration 38 -- +bool(false) +-- Iteration 39 -- +bool(false) +-- Iteration 40 -- +bool(false) +-- Iteration 41 -- +bool(false) +-- Iteration 42 -- +bool(false) +-- Iteration 43 -- +bool(false) +-- Iteration 44 -- +bool(false) +-- Iteration 45 -- +bool(false) +-- Iteration 46 -- +bool(false) +-- Iteration 47 -- +bool(false) +-- Iteration 48 -- +bool(false) +-- Iteration 49 -- +bool(false) +-- Iteration 50 -- +bool(false) +-- Iteration 51 -- +bool(false) +-- Iteration 52 -- +bool(false) +-- Iteration 53 -- +bool(false) +-- Iteration 54 -- +bool(false) +-- Iteration 55 -- +bool(false) +-- Iteration 56 -- +bool(false) +-- Iteration 57 -- +bool(false) +-- Iteration 58 -- +bool(false) +-- Iteration 59 -- +bool(false) + +*** Testing error conditions *** + +Warning: is_null() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_null() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/is_object.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/is_object.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/is_object.phpt:1.2 --- /dev/null Sat May 12 12:18:13 2007 +++ php-src/ext/standard/tests/general_functions/is_object.phpt Sat May 12 12:18:13 2007 @@ -0,0 +1,228 @@ +--TEST-- +Test is_object() function +--FILE-- +<?php +/* Prototype: bool is_object ( mixed $var ); + * Description: Finds whether the given variable is an object + */ + +echo "*** Testing is_object() with valid objects ***\n"; + +// class with no members +class foo +{ +// no members +} + +// abstract class +abstract class abstractClass +{ + abstract protected function getClassName(); + public function printClassName () { + echo $this->getClassName() . "\n"; + } +} + +// implement abstract class +class concreteClass extends abstractClass +{ + protected function getClassName() { + return "concreteClass"; + } +} + +// interface class +interface IValue +{ + public function setVal ($name, $val); + public function dumpVal (); +} + +// implement the interface +class Value implements IValue +{ + private $vars = array (); + + public function setVal ( $name, $val ) { + $this->vars[$name] = $val; + } + + public function dumpVal () { + var_dump ( $vars ); + } +} + +// a gereral class +class myClass +{ + var $foo_object; + public $public_var; + public $public_var1; + private $private_var; + protected $protected_var; + + function myClass ( ) { + $this->foo_object = new foo(); + $this->public_var = 10; + $this->public_var1 = new foo(); + $this->private_var = new foo(); + $this->proected_var = new foo(); + } +} + +// create a object of each class defined above +$myClass_object = new myClass(); +$foo_object = new foo(); +$Value_object = new Value(); +$concreteClass_object = new concreteClass(); + +$valid_objects = array( + new stdclass, + new foo, + new concreteClass, + new Value, + new myClass, + $myClass_object, + $myClass_object->foo_object, + $myClass_object->public_var1, + $foo_object, + $Value_object, + $concreteClass_object +); + +/* loop to check that is_object() recognizes different + objects, expected output: bool(true) */ +$loop_counter = 1; +foreach ($valid_objects as $object ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_object($object) ); +} + +echo "\n*** Testing is_object() on non object types ***\n"; + +// get a resource type variable +$fp = fopen (__FILE__, "r"); +$dfp = opendir ( dirname(__FILE__) ); + +// unset object +$unset_object = new foo(); +unset ($unset_object); + +// other types in a array +$not_objects = array ( + 0, + -1, + 0.1, + -10.0000000000000000005, + 10.5e+5, + 0xFF, + 0123, + $fp, // resource + $dfp, + array(), + array("string"), + "0", + "1", + "", + true, + NULL, + null, + @$unset_object, // unset object + @$undefined_var, // undefined variable +); +/* loop through the $not_objects to see working of + is_object() on non object types, expected output: bool(false) */ +$loop_counter = 1; +foreach ($not_objects as $type ) { + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + var_dump( is_object($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( is_object() ); + +//arguments more than expected +var_dump( is_object($myClass_object, $myClass_object) ); + +echo "Done\n"; +?> + +--CLEAN-- +// close the resources used +fclose($fp); +closedir($dfp); + +--EXPECTF-- +*** Testing is_object() with valid objects *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) +-- Iteration 11 -- +bool(true) + +*** Testing is_object() on non object types *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) + +*** Testing error conditions *** + +Warning: is_object() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_object() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/debug_zval_dump_b.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/debug_zval_dump_b.phpt
« previous php.cvs (#44278) next »