1--TEST--
2Test printf() function : error conditions
3--FILE--
4<?php
5/* Prototype  : int printf  ( string $format  [, mixed $args  [, mixed $...  ]] )
6 * Description: Produces output according to format .
7 * Source code: ext/standard/formatted_print.c
8 */
9
10echo "*** Testing printf() : error conditions ***\n";
11
12// Zero arguments
13echo "\n-- Testing printf() function with Zero arguments --\n";
14var_dump( printf() );
15
16echo "\n-- Testing printf() function with less than expected no. of arguments --\n";
17$format1 = '%s';
18$format2 = '%s%s';
19$format3 = '%s%s%s';
20$arg1 = 'one';
21$arg2 = 'two';
22
23echo "\n-- Call printf with one argument less than expected --\n";
24var_dump( printf($format1) );
25var_dump( printf($format2,$arg1) );
26var_dump( printf($format3,$arg1,$arg2) );
27
28echo "\n-- Call printf with two argument less than expected --\n";
29var_dump( printf($format2) );
30var_dump( printf($format3,$arg1) );
31
32echo "\n-- Call printf with three argument less than expected --\n";
33var_dump( printf($format3) );
34
35?>
36===DONE===
37--EXPECTF--
38*** Testing printf() : error conditions ***
39
40-- Testing printf() function with Zero arguments --
41
42Warning: printf() expects at least 1 parameter, 0 given in %s on line %d
43bool(false)
44
45-- Testing printf() function with less than expected no. of arguments --
46
47-- Call printf with one argument less than expected --
48
49Warning: printf(): Too few arguments in %s on line %d
50bool(false)
51
52Warning: printf(): Too few arguments in %s on line %d
53bool(false)
54
55Warning: printf(): Too few arguments in %s on line %d
56bool(false)
57
58-- Call printf with two argument less than expected --
59
60Warning: printf(): Too few arguments in %s on line %d
61bool(false)
62
63Warning: printf(): Too few arguments in %s on line %d
64bool(false)
65
66-- Call printf with three argument less than expected --
67
68Warning: printf(): Too few arguments in %s on line %d
69bool(false)
70===DONE===
71