1--TEST--
2Test array_walk() function : error conditions
3--FILE--
4<?php
5/* Prototype  : bool array_walk(array $input, string $funcname [, mixed $userdata])
6 * Description: Apply a user function to every member of an array
7 * Source code: ext/standard/array.c
8*/
9
10$input = array(1, 2);
11
12/* Prototype : callback(mixed value, mixed key, mixed user_data)
13 * Parameters : value - value in key/value pair
14 *              key - key in key/value pair
15 *              user_data - extra parameter
16 */
17function callback ($value, $key, $user_data) {
18  echo "\ncallback() invoked \n";
19}
20
21echo "*** Testing array_walk() : error conditions ***\n";
22
23echo "-- Testing array_walk() function with zero arguments --\n";
24var_dump( array_walk() );
25
26echo "-- Testing array_walk() function with one argument --\n";
27var_dump( array_walk($input) );
28
29echo "-- Testing array_walk() function with non existent callback function  --\n";
30var_dump( array_walk($input, "non_existent") );
31
32echo "Done";
33?>
34--EXPECTF--
35*** Testing array_walk() : error conditions ***
36-- Testing array_walk() function with zero arguments --
37
38Warning: array_walk() expects at least 2 parameters, 0 given in %s on line %d
39NULL
40-- Testing array_walk() function with one argument --
41
42Warning: array_walk() expects at least 2 parameters, 1 given in %s on line %d
43NULL
44-- Testing array_walk() function with non existent callback function  --
45
46Warning: array_walk() expects parameter 2 to be a valid callback, function 'non_existent' not found or invalid function name in %s on line %d
47NULL
48Done
49