1--TEST--
2Test sprintf() function : usage variations - char formats with boolean values
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() : char formats with boolean values ***\n";
11
12// array of boolean values
13$boolean_values = array(
14  true,
15  false,
16  TRUE,
17  FALSE,
18);
19
20// array of char formats
21$char_formats = array(
22  "%c", "%hc", "%lc",
23  "%Lc", " %c", "%c ",
24  "\t%c", "\n%c", "%4c",
25  "%30c", "%[a-bA-B@#$&]", "%*c"
26);
27
28$count = 1;
29foreach($boolean_values as $boolean_value) {
30  echo "\n-- Iteration $count --\n";
31
32  foreach($char_formats as $format) {
33    var_dump( sprintf($format, $boolean_value) );
34  }
35  $count++;
36};
37
38echo "Done";
39?>
40--EXPECT--
41*** Testing sprintf() : char formats with boolean values ***
42
43-- Iteration 1 --
44string(1) ""
45string(1) "c"
46string(1) ""
47string(1) "c"
48string(2) " "
49string(2) " "
50string(2) "	"
51string(2) "
52"
53string(1) ""
54string(1) ""
55string(11) "a-bA-B@#$&]"
56string(1) "c"
57
58-- Iteration 2 --
59string(1) "�"
60string(1) "c"
61string(1) "�"
62string(1) "c"
63string(2) " �"
64string(2) "� "
65string(2) "	�"
66string(2) "
67�"
68string(1) "�"
69string(1) "�"
70string(11) "a-bA-B@#$&]"
71string(1) "c"
72
73-- Iteration 3 --
74string(1) ""
75string(1) "c"
76string(1) ""
77string(1) "c"
78string(2) " "
79string(2) " "
80string(2) "	"
81string(2) "
82"
83string(1) ""
84string(1) ""
85string(11) "a-bA-B@#$&]"
86string(1) "c"
87
88-- Iteration 4 --
89string(1) "�"
90string(1) "c"
91string(1) "�"
92string(1) "c"
93string(2) " �"
94string(2) "� "
95string(2) "	�"
96string(2) "
97�"
98string(1) "�"
99string(1) "�"
100string(11) "a-bA-B@#$&]"
101string(1) "c"
102Done
103