1--TEST--
2Test sprintf() function : usage variations - hexa 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() : hexa 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 hexa formats
21$hexa_formats = array(
22  "%x", "%xx", "%lx",
23  "%Lx", " %x", "%x ",
24  "\t%x", "\n%x", "%4x",
25  "%30x", "%[0-9A-Fa-f]", "%*x"
26);
27
28$count = 1;
29foreach($boolean_values as $boolean_value) {
30  echo "\n-- Iteration $count --\n";
31
32  foreach($hexa_formats as $format) {
33    var_dump( sprintf($format, $boolean_value) );
34  }
35  $count++;
36};
37
38echo "Done";
39?>
40--EXPECTF--
41*** Testing sprintf() : hexa formats with boolean values ***
42
43-- Iteration 1 --
44string(1) "1"
45string(2) "1x"
46string(1) "1"
47string(1) "x"
48string(2) " 1"
49string(2) "1 "
50string(2) "	1"
51string(2) "
521"
53string(4) "   1"
54string(30) "                             1"
55string(10) "0-9A-Fa-f]"
56string(1) "x"
57
58-- Iteration 2 --
59string(1) "0"
60string(2) "0x"
61string(1) "0"
62string(1) "x"
63string(2) " 0"
64string(2) "0 "
65string(2) "	0"
66string(2) "
670"
68string(4) "   0"
69string(30) "                             0"
70string(10) "0-9A-Fa-f]"
71string(1) "x"
72
73-- Iteration 3 --
74string(1) "1"
75string(2) "1x"
76string(1) "1"
77string(1) "x"
78string(2) " 1"
79string(2) "1 "
80string(2) "	1"
81string(2) "
821"
83string(4) "   1"
84string(30) "                             1"
85string(10) "0-9A-Fa-f]"
86string(1) "x"
87
88-- Iteration 4 --
89string(1) "0"
90string(2) "0x"
91string(1) "0"
92string(1) "x"
93string(2) " 0"
94string(2) "0 "
95string(2) "	0"
96string(2) "
970"
98string(4) "   0"
99string(30) "                             0"
100string(10) "0-9A-Fa-f]"
101string(1) "x"
102Done