Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_basic1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
10: echo "*** 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
22: var_dump( sprintf($format) );
23:
24: // Calling sprintf() with two arguments
25: var_dump( sprintf($format1, $arg1) );
26:
27: // Calling sprintf() with three arguments
28: var_dump( sprintf($format2, $arg1, $arg2) );
29:
30: // Calling sprintf() with four arguments
31: var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
32:
33: echo "Done";
34: ?>
35: --EXPECTF--
36: *** Testing sprintf() : basic functionality - using string format ***
37: string(6) "format"
38: string(13) "arg1 argument"
39: string(27) "arg1 argument arg2 argument"
40: string(41) "arg1 argument arg2 argument arg3 argument"
41: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>