2 /* Prototype : bool sort(array &array_arg [, int $sort_flags])
3 * Description: Sort an array
4 * Source code: ext/standard/array.c
8 * Testing sort() by providing different unexpected values for flag argument
11 echo "*** Testing sort() : usage variations ***\n";
13 //get an unset variable
18 $fp = fopen(__FILE__
, "r");
20 // temperory array for checking unexpected behavior
21 $unsorted_values = array(10, 2, 45);
23 //array of values to iterate over
24 $unexpected_values = array(
55 /*16*/ new stdclass(),
58 /*17*/ @undefined_var
,
68 // loop though each element of the array and check the working of sort()
69 // when $flag argument is supplied with different values
70 echo "\n-- Testing sort() by supplying different unexpected values for 'flag' argument --\n";
73 for($index = 0; $index < count($unexpected_values); $index ++
) {
74 echo "-- Iteration $counter --\n";
76 // sort the array, retain a temp. copy of input array for next iteration
77 $value = $unexpected_values [$index];
78 $temp_array = $unsorted_values;
79 var_dump( sort($temp_array, $value) );
81 //dump the sorted array
82 var_dump($temp_array);