1--TEST--
2Test sprintf() function : usage variations - char formats with char values
3--FILE--
4<?php
5echo "*** Testing sprintf() : char formats with char values ***\n";
6
7// array of char values
8$char_values = array( 'a', "a", 67, -67, 99, ' ', '', 'A', "A" );
9
10// array of char formats
11$char_formats = array(
12  "%c", "%lc", " %c", "%c ",
13  "\t%c", "\n%c", "%4c", "%30c",
14);
15
16$count = 1;
17foreach($char_values as $char_value) {
18  echo "\n-- Iteration $count --\n";
19
20  foreach($char_formats as $format) {
21    var_dump( sprintf($format, $char_value) );
22  }
23  $count++;
24};
25
26echo "Done";
27?>
28--EXPECT--
29*** Testing sprintf() : char formats with char values ***
30
31-- Iteration 1 --
32string(1) "�"
33string(1) "�"
34string(2) " �"
35string(2) "� "
36string(2) "	�"
37string(2) "
38�"
39string(1) "�"
40string(1) "�"
41
42-- Iteration 2 --
43string(1) "�"
44string(1) "�"
45string(2) " �"
46string(2) "� "
47string(2) "	�"
48string(2) "
49�"
50string(1) "�"
51string(1) "�"
52
53-- Iteration 3 --
54string(1) "C"
55string(1) "C"
56string(2) " C"
57string(2) "C "
58string(2) "	C"
59string(2) "
60C"
61string(1) "C"
62string(1) "C"
63
64-- Iteration 4 --
65string(1) "�"
66string(1) "�"
67string(2) " �"
68string(2) "� "
69string(2) "	�"
70string(2) "
71�"
72string(1) "�"
73string(1) "�"
74
75-- Iteration 5 --
76string(1) "c"
77string(1) "c"
78string(2) " c"
79string(2) "c "
80string(2) "	c"
81string(2) "
82c"
83string(1) "c"
84string(1) "c"
85
86-- Iteration 6 --
87string(1) "�"
88string(1) "�"
89string(2) " �"
90string(2) "� "
91string(2) "	�"
92string(2) "
93�"
94string(1) "�"
95string(1) "�"
96
97-- Iteration 7 --
98string(1) "�"
99string(1) "�"
100string(2) " �"
101string(2) "� "
102string(2) "	�"
103string(2) "
104�"
105string(1) "�"
106string(1) "�"
107
108-- Iteration 8 --
109string(1) "�"
110string(1) "�"
111string(2) " �"
112string(2) "� "
113string(2) "	�"
114string(2) "
115�"
116string(1) "�"
117string(1) "�"
118
119-- Iteration 9 --
120string(1) "�"
121string(1) "�"
122string(2) " �"
123string(2) "� "
124string(2) "	�"
125string(2) "
126�"
127string(1) "�"
128string(1) "�"
129Done
130