Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_basic9.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : basic functionality - hexadecimal 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 hexadecimal format ***\n";
11:
12: // Initialise all required variables
13:
14: // Initialising different format strings
15: $format = "format";
16: $format1 = "%x";
17: $format2 = "%x %x";
18: $format3 = "%x %x %x";
19:
20: $format11 = "%X";
21: $format22 = "%X %X";
22: $format33 = "%X %X %X";
23:
24: $arg1 = 11;
25: $arg2 = 132;
26: $arg3 = 177;
27:
28: // Calling sprintf() with default arguments
29: var_dump( sprintf($format) );
30:
31: // Calling sprintf() with two arguments
32: var_dump( sprintf($format1, $arg1) );
33: var_dump( sprintf($format11, $arg1) );
34:
35: // Calling sprintf() with three arguments
36: var_dump( sprintf($format2, $arg1, $arg2) );
37: var_dump( sprintf($format22, $arg1, $arg2) );
38:
39: // Calling sprintf() with four arguments
40: var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
41: var_dump( sprintf($format33, $arg1, $arg2, $arg3) );
42:
43: echo "Done";
44: ?>
45: --EXPECTF--
46: *** Testing sprintf() : basic functionality - using hexadecimal format ***
47: string(6) "format"
48: string(1) "b"
49: string(1) "B"
50: string(4) "b 84"
51: string(4) "B 84"
52: string(7) "b 84 b1"
53: string(7) "B 84 B1"
54: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>