1--TEST-- 2Test array_intersect_ukey() function : error conditions 3--FILE-- 4<?php 5/* Prototype : array array_intersect_ukey(array arr1, array arr2 [, array ...], callback key_compare_func) 6 * Description: Computes the intersection of arrays using a callback function on the keys for comparison. 7 * Source code: ext/standard/array.c 8 */ 9 10echo "*** Testing array_intersect_ukey() : error conditions ***\n"; 11 12//Initialise arguments 13$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); 14$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); 15 16//Call back function 17function key_compare_func($key1, $key2) 18{ 19 if ($key1 == $key2) 20 return 0; 21 else 22 return ($key1 > $key2)? 1:-1; 23} 24 25//Test array_intersect_ukey with one more than the expected number of arguments 26echo "\n-- Testing array_intersect_ukey() function with more than expected no. of arguments --\n"; 27$extra_arg = 10; 28var_dump( array_intersect_ukey($array1, $array2, 'key_compare_func',$extra_arg) ); 29 30// Testing array_intersect_ukey with one less than the expected number of arguments 31echo "\n-- Testing array_intersect_ukey() function with less than expected no. of arguments --\n"; 32var_dump( array_intersect_ukey($array1, $array2) ); 33 34// Testing array_intersect_ukey with no arguments 35echo "\n-- Testing array_intersect_ukey() function with no arguments --\n"; 36var_dump( array_intersect_ukey() ); 37?> 38===DONE=== 39--EXPECTF-- 40*** Testing array_intersect_ukey() : error conditions *** 41 42-- Testing array_intersect_ukey() function with more than expected no. of arguments -- 43 44Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d 45NULL 46 47-- Testing array_intersect_ukey() function with less than expected no. of arguments -- 48 49Warning: array_intersect_ukey(): at least 3 parameters are required, 2 given in %s on line %d 50NULL 51 52-- Testing array_intersect_ukey() function with no arguments -- 53 54Warning: array_intersect_ukey(): at least 3 parameters are required, 0 given in %s on line %d 55NULL 56===DONE===