Return to array_reduce_variation1.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_reduce() function : variation 3: --FILE-- 4: <?php 5: /* Prototype : mixed array_reduce(array input, mixed callback [, int initial]) 6: * Description: Iteratively reduce the array to a single value via the callback. 7: * Source code: ext/standard/array.c 8: * Alias to functions: 9: */ 10: 11: echo "*** Testing array_reduce() : variation ***\n"; 12: 13: 14: function oneArg($v) { 15: return $v; 16: } 17: 18: function threeArgs($v, $w, $x) { 19: return $v + $w + $x; 20: } 21: 22: $array = array(1); 23: 24: echo "\n--- Testing with a callback with too few parameters ---\n"; 25: var_dump(array_reduce($array, "oneArg", 2)); 26: 27: echo "\n--- Testing with a callback with too many parameters ---\n"; 28: var_dump(array_reduce($array, "threeArgs", 2)); 29: 30: ?> 31: ===DONE=== 32: --EXPECTF-- 33: *** Testing array_reduce() : variation *** 34: 35: --- Testing with a callback with too few parameters --- 36: int(2) 37: 38: --- Testing with a callback with too many parameters --- 39: 40: Warning: Missing argument 3 for threeArgs() in %sarray_reduce_variation1.php on line %d 41: 42: Notice: Undefined variable: x in %sarray_reduce_variation1.php on line %d 43: int(3) 44: ===DONE===