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