1--TEST--
2Test sprintf() function : basic functionality - string format
3--FILE--
4<?php
5/* Prototype  : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
6 * Description: Return a formatted string
7 * Source code: ext/standard/formatted_print.c
8*/
9
10echo "*** Testing sprintf() : 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
21// Calling sprintf() with default arguments
22var_dump( sprintf($format) );
23
24// Calling sprintf() with two arguments
25var_dump( sprintf($format1, $arg1) );
26
27// Calling sprintf() with three arguments
28var_dump( sprintf($format2, $arg1, $arg2) );
29
30// Calling sprintf() with four arguments
31var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
32
33echo "Done";
34?>
35--EXPECT--
36*** Testing sprintf() : basic functionality - using string format ***
37string(6) "format"
38string(13) "arg1 argument"
39string(27) "arg1 argument arg2 argument"
40string(41) "arg1 argument arg2 argument arg3 argument"
41Done
42