1--TEST--
2Test extract() function (error conditions)
3--FILE--
4<?php
5
6/* Testing Error Conditions */
7echo "*** Testing Error Conditions ***\n";
8
9/* Zero Arguments */
10var_dump( extract() );
11
12/* Invalid second argument ( only 0-6 is valid) */
13$arr = array(1);
14var_dump( extract($arr, -1 . "wddr") );
15var_dump( extract($arr, 7 , "wddr") );
16
17/* scalar argument */
18$val = 1;
19var_dump( extract($val) );
20
21/* string argument */
22$str = "test";
23var_dump( extract($str) );
24
25/* More than valid number of arguments i.e. 3 args */
26var_dump( extract($arr, EXTR_SKIP, "aa", "ee") );
27
28/* Two Arguments, second as prefix but without prefix string as third argument */
29var_dump( extract($arr,EXTR_PREFIX_IF_EXISTS) );
30
31echo "Done\n";
32?>
33
34--EXPECTF--
35*** Testing Error Conditions ***
36
37Warning: extract() expects at least 1 parameter, 0 given in %s on line %d
38NULL
39
40Notice: A non well formed numeric value encountered in %s on line %d
41
42Warning: extract(): Invalid extract type in %s on line %d
43NULL
44
45Warning: extract(): Invalid extract type in %s on line %d
46NULL
47
48Warning: extract() expects parameter 1 to be array, integer given in %s on line %d
49NULL
50
51Warning: extract() expects parameter 1 to be array, string given in %s on line %d
52NULL
53
54Warning: extract() expects at most 3 parameters, 4 given in %s on line %d
55NULL
56
57Warning: extract(): specified extract type requires the prefix parameter in %s on line %d
58NULL
59Done
60