2 /* Prototype: bool is_bool ( mixed $var );
3 * Description: Finds whether the given variable is a boolean
6 echo "*** Testing is_bool() with valid boolean values ***\n";
7 // different valid boolean vlaues
14 /* loop to check that is_bool() recognizes different
15 bool values, expected output: bool(true) */
17 foreach ($valid_bools as $bool_val ) {
18 echo "-- Iteration $loop_counter --\n"; $loop_counter++
;
19 var_dump( is_bool($bool_val) );
22 echo "\n*** Testing is_bool() on non boolean values ***\n";
24 // get a resource type variable
25 $fp = fopen (__FILE__
, "r");
26 $dfp = opendir ( dirname(__FILE__
) );
36 // other types in a array
37 $not_bool_types = array (
78 10.0000000000000000005,
111 array(1 => "One", "two" => 2),
113 /* unset bool vars and undefined var */
119 /* loop through the $not_bool_types to see working of
120 is_bool() on non bull types, expected output: bool(false) */
122 foreach ($not_bool_types as $type ) {
123 echo "-- Iteration $loop_counter --\n"; $loop_counter++
;
124 var_dump( is_bool($type) );
127 echo "\n*** Testing error conditions ***\n";
129 var_dump( is_bool() );
131 //arguments more than expected
132 var_dump( is_bool(TRUE, FALSE) );