1--TEST--
2Test array_key_exists() function : error conditions - Pass incorrect number of args
3--FILE--
4<?php
5/* Prototype  : bool array_key_exists(mixed $key, array $search)
6 * Description: Checks if the given key or index exists in the array
7 * Source code: ext/standard/array.c
8 * Alias to functions: key_exists
9 */
10
11/*
12 * Pass incorrect number of arguments to array_key_exists() to test behaviour
13 */
14
15echo "*** Testing array_key_exists() : error conditions ***\n";
16
17//Test array_key_exists with one more than the expected number of arguments
18echo "\n-- Testing array_key_exists() function with more than expected no. of arguments --\n";
19$key = 1;
20$search = array(1, 2);
21$extra_arg = 10;
22var_dump( array_key_exists($key, $search, $extra_arg) );
23
24// Testing array_key_exists with one less than the expected number of arguments
25echo "\n-- Testing array_key_exists() function with less than expected no. of arguments --\n";
26$key = 1;
27var_dump( array_key_exists($key) );
28
29echo "Done";
30?>
31
32--EXPECTF--
33*** Testing array_key_exists() : error conditions ***
34
35-- Testing array_key_exists() function with more than expected no. of arguments --
36
37Warning: array_key_exists() expects exactly 2 parameters, 3 given in %s on line %d
38NULL
39
40-- Testing array_key_exists() function with less than expected no. of arguments --
41
42Warning: array_key_exists() expects exactly 2 parameters, 1 given in %s on line %d
43NULL
44Done