1--TEST--
2Test printf() function : basic functionality - string format
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() : basic functionality - using string format ***\n";
11
12// Initialise all required variables
13$format = "format";
14$format1 = "%s";
15$format2 = "%s %s";
16$format3 = "%s %s %s";
17$arg1 = "arg1 argument";
18$arg2 = "arg2 argument";
19$arg3 = "arg3 argument";
20
21echo "\n-- Calling printf() with no arguments --\n";
22$result = printf($format);
23echo "\n";
24var_dump($result);
25
26echo "\n-- Calling printf() with one arguments --\n";
27$result = printf($format1, $arg1);
28echo "\n";
29var_dump($result);
30
31echo "\n-- Calling printf() with two arguments --\n";
32$result = printf($format2, $arg1, $arg2);
33echo "\n";
34var_dump($result);
35
36
37echo "\n-- Calling printf() with string three arguments --\n";
38$result = printf($format3, $arg1, $arg2, $arg3);
39echo "\n";
40var_dump($result);
41
42?>
43===DONE===
44--EXPECT--
45*** Testing printf() : basic functionality - using string format ***
46
47-- Calling printf() with no arguments --
48format
49int(6)
50
51-- Calling printf() with one arguments --
52arg1 argument
53int(13)
54
55-- Calling printf() with two arguments --
56arg1 argument arg2 argument
57int(27)
58
59-- Calling printf() with string three arguments --
60arg1 argument arg2 argument arg3 argument
61int(41)
62===DONE===
63