1--TEST--
2Test sprintf() function : usage variations - with whitespaces in format strings
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() : with  white spaces in format strings ***\n";
11
12// initializing the format array
13$formats = array(
14  "% d", "%  d", "%   d",
15  "% f", "%  f", "%   f",
16  "% F", "%  F", "%   F",
17  "% b", "%  b", "%   b",
18  "% c", "%  c", "%   c",
19  "% e", "%  e", "%   e",
20  "% u", "%  u", "%   u",
21  "% o", "%  o", "%   o",
22  "% x", "%  x", "%   x",
23  "% X", "%  X", "%   X",
24  "% E", "%  E", "%   E"
25);
26
27// initializing the args array
28
29foreach($formats as $format) {
30  var_dump( sprintf($format, 1234) );
31}
32
33echo "Done";
34?>
35--EXPECTF--
36*** Testing sprintf() : with  white spaces in format strings ***
37string(4) "1234"
38string(4) "1234"
39string(4) "1234"
40string(11) "1234.000000"
41string(11) "1234.000000"
42string(11) "1234.000000"
43string(11) "1234.000000"
44string(11) "1234.000000"
45string(11) "1234.000000"
46string(11) "10011010010"
47string(11) "10011010010"
48string(11) "10011010010"
49string(1) "�"
50string(1) "�"
51string(1) "�"
52string(11) "1.234000e+3"
53string(11) "1.234000e+3"
54string(11) "1.234000e+3"
55string(4) "1234"
56string(4) "1234"
57string(4) "1234"
58string(4) "2322"
59string(4) "2322"
60string(4) "2322"
61string(3) "4d2"
62string(3) "4d2"
63string(3) "4d2"
64string(3) "4D2"
65string(3) "4D2"
66string(3) "4D2"
67string(11) "1.234000E+3"
68string(11) "1.234000E+3"
69string(11) "1.234000E+3"
70Done
71