summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/key_error.phpt
blob: ae63bff07db0fd895b64494b557b67ab07d4f8a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--TEST--
Test key() function : error conditions - Pass incorrect number of args
--FILE--
<?php
/* Prototype  : mixed key(array $array_arg)
 * Description: Return the key of the element currently pointed to by the internal array pointer
 * Source code: ext/standard/array.c
 */

/*
 * Pass incorrect number of arguments to key() to test behaviour
 */

echo "*** Testing key() : error conditions ***\n";

// Zero arguments
echo "\n-- Testing key() function with Zero arguments --\n";
var_dump( key() );

//Test current with one more than the expected number of arguments
echo "\n-- Testing key() function with more than expected no. of arguments --\n";
$array_arg = array(1, 2);
$extra_arg = 10;
var_dump( key($array_arg, $extra_arg) );
?>
===DONE===
--EXPECTF--
*** Testing key() : error conditions ***

-- Testing key() function with Zero arguments --

Warning: Wrong parameter count for key() in %s on line %d
NULL

-- Testing key() function with more than expected no. of arguments --

Warning: Wrong parameter count for key() in %s on line %d
NULL
===DONE===