1--TEST--
2Test 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
10echo "*** 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
29var_dump( sprintf($format) );
30
31// Calling sprintf() with two arguments
32var_dump( sprintf($format1, $arg1) );
33var_dump( sprintf($format11, $arg1) );
34
35// Calling sprintf() with three arguments
36var_dump( sprintf($format2, $arg1, $arg2) );
37var_dump( sprintf($format22, $arg1, $arg2) );
38
39// Calling sprintf() with four arguments
40var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
41var_dump( sprintf($format33, $arg1, $arg2, $arg3) );
42
43echo "Done";
44?>
45--EXPECT--
46*** Testing sprintf() : basic functionality - using hexadecimal format ***
47string(6) "format"
48string(1) "b"
49string(1) "B"
50string(4) "b 84"
51string(4) "B 84"
52string(7) "b 84 b1"
53string(7) "B 84 B1"
54Done
55