2 Test is_null() function
5 /* Prototype: bool is_null ( mixed $var );
6 * Description: Finds whether the given variable is NULL
9 echo "*** Testing is_null() with valid null values ***\n";
10 // different valid null values
11 $unset_array = array();
15 $unset_object = new stdclass;
16 $unset_resource = fopen(__FILE__, "r");
17 // unset them to make it null.
18 unset ($unset_array, $unset_int, $unset_float, $unset_bool, $unset_object, $unset_resource);
35 /* loop to check that is_null() recognizes different
36 null values, expected output: bool(true) */
38 foreach ($valid_nulls as $null_val ) {
39 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
40 var_dump( is_null($null_val) );
43 echo "\n*** Testing is_bool() on non null values ***\n";
45 // get a resource type variable
46 $fp = fopen (__FILE__, "r");
47 $dfp = opendir ( __DIR__ );
49 // other types in a array
50 $not_null_types = array (
91 10.0000000000000000005,
120 array(1 => "One", "two" => 2),
122 /* loop through the $not_null_types to see working of
123 is_null() on non null types, expected output: bool(false) */
125 foreach ($not_null_types as $type ) {
126 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
127 var_dump( is_null($type) );
132 // close the resources used
138 *** Testing is_null() with valid null values ***
162 *** Testing is_bool() on non null values ***