1--TEST-- 2Test array_map() function : error conditions 3--FILE-- 4<?php 5/* Prototype : array array_map ( callback $callback , array $arr1 [, array $... ] ) 6 * Description: Applies the callback to the elements of the given arrays 7 * Source code: ext/standard/array.c 8 */ 9 10echo "*** Testing array_map() : error conditions ***\n"; 11 12// Zero arguments 13echo "\n-- Testing array_map() function with Zero arguments --\n"; 14var_dump( array_map() ); 15 16// Testing array_map with one less than the expected number of arguments 17echo "\n-- Testing array_map() function with one less than expected no. of arguments --\n"; 18function callback1() { 19 return 1; 20} 21var_dump( array_map('callback1') ); 22 23echo "\n-- Testing array_map() function with less no. of arrays than callback function arguments --\n"; 24$arr1 = array(1, 2); 25function callback2($p, $q) { 26 return $p * $q; 27} 28var_dump( array_map('callback2', $arr1) ); 29 30echo "\n-- Testing array_map() function with more no. of arrays than callback function arguments --\n"; 31$arr2 = array(3, 4); 32$arr3 = array(5, 6); 33var_dump( array_map('callback2', $arr1, $arr2, $arr3) ); 34 35echo "Done"; 36?> 37--EXPECTF-- 38*** Testing array_map() : error conditions *** 39 40-- Testing array_map() function with Zero arguments -- 41 42Warning: array_map() expects at least 2 parameters, 0 given in %s on line %d%d 43NULL 44 45-- Testing array_map() function with one less than expected no. of arguments -- 46 47Warning: array_map() expects at least 2 parameters, 1 given in %s on line %d%d 48NULL 49 50-- Testing array_map() function with less no. of arrays than callback function arguments -- 51 52Warning: Missing argument 2 for callback2() in %s on line %d%d 53 54Notice: Undefined variable: q in %s on line %d%d 55 56Warning: Missing argument 2 for callback2() in %s on line %d%d 57 58Notice: Undefined variable: q in %s on line %d%d 59array(2) { 60 [0]=> 61 int(0) 62 [1]=> 63 int(0) 64} 65 66-- Testing array_map() function with more no. of arrays than callback function arguments -- 67array(2) { 68 [0]=> 69 int(3) 70 [1]=> 71 int(8) 72} 73Done 74