2 Test is_bool() function
5 /* Prototype: bool is_bool ( mixed $var );
6 * Description: Finds whether the given variable is a boolean
9 echo "*** Testing is_bool() with valid boolean values ***\n";
10 // different valid boolean values
17 /* loop to check that is_bool() recognizes different
18 bool values, expected output: bool(true) */
20 foreach ($valid_bools as $bool_val ) {
21 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
22 var_dump( is_bool($bool_val) );
25 echo "\n*** Testing is_bool() on non boolean values ***\n";
27 // get a resource type variable
28 $fp = fopen (__FILE__, "r");
29 $dfp = opendir ( __DIR__ );
39 // other types in a array
40 $not_bool_types = array (
81 10.0000000000000000005,
114 array(1 => "One", "two" => 2),
116 /* unset bool vars and undefined var */
122 /* loop through the $not_bool_types to see working of
123 is_bool() on non bull types, expected output: bool(false) */
125 foreach ($not_bool_types as $type ) {
126 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
127 var_dump( is_bool($type) );
138 *** Testing is_bool() with valid boolean values ***
148 *** Testing is_bool() on non boolean values ***