import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / usort_error2.php
blobc3c3ebfa31236119f7e514afd01eb9e95c9d41d8
1 <?php
2 /* Prototype : bool usort(array $array_arg, string $cmp_function)
3 * Description: Sort an array by values using a user-defined comparison function
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass an unknown comparison function to usort() to test behaviour.
9 * Pass incorrect number of arguments and an unknown function to test which error
10 * is generated.
13 echo "*** Testing usort() : error conditions ***\n";
15 function cmp($value1, $value2)
17 if($value1 == $value2) {
18 return 0;
20 else if($value1 > $value2) {
21 return 1;
23 else {
24 return -1;
28 // Initialize 'array_arg'
29 $array_arg = array(0 => 1, 1 => 10, 2 => 'string', 3 => 3, 4 => 2, 5 => 100, 6 => 25);
30 $extra_arg = 10;
32 // With non existent comparison function
33 echo "\n-- Testing usort() function with non-existent compare function --\n";
34 var_dump( usort($array_arg, 'non_existent') );
36 // With non existent comparison function and extra arguemnt
37 echo "\n-- Testing usort() function with non-existent compare function and extra argument --\n";
38 var_dump( usort($array_arg, 'non_existent', $extra_arg) );
40 ===DONE===