1--TEST--
2Test sprintf() function : usage variations - scientific formats with string 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 string values ***\n";
11
12// array of string values
13$string_values = array(
14  "",
15  '',
16  "0",
17  '0',
18  "1",
19  '1',
20  "\x01",
21  '\x01',
22  "\01",
23  '\01',
24  'string',
25  "string",
26  "true",
27  "FALSE",
28  'false',
29  'TRUE',
30  "NULL",
31  'null',
32  "333333333333333333333333333333"
33);
34
35// array of scientific formats
36$scientific_formats = array(
37  "%e", "%he", "%le",
38  "%Le", " %e", "%e ",
39  "\t%e", "\n%e", "%4e",
40  "%30e", "%[0-1]", "%*e"
41);
42
43
44$count = 1;
45foreach($string_values as $string_value) {
46  echo "\n-- Iteration $count --\n";
47
48  foreach($scientific_formats as $format) {
49    var_dump( sprintf($format, $string_value) );
50  }
51  $count++;
52};
53
54echo "Done";
55?>
56--EXPECTF--
57*** Testing sprintf() : scientific formats with string values ***
58
59-- Iteration 1 --
60string(11) "0.000000e+0"
61string(1) "e"
62string(11) "0.000000e+0"
63string(1) "e"
64string(12) " 0.000000e+0"
65string(12) "0.000000e+0 "
66string(12) "	0.000000e+0"
67string(12) "
680.000000e+0"
69string(11) "0.000000e+0"
70string(30) "                   0.000000e+0"
71string(4) "0-1]"
72string(1) "e"
73
74-- Iteration 2 --
75string(11) "0.000000e+0"
76string(1) "e"
77string(11) "0.000000e+0"
78string(1) "e"
79string(12) " 0.000000e+0"
80string(12) "0.000000e+0 "
81string(12) "	0.000000e+0"
82string(12) "
830.000000e+0"
84string(11) "0.000000e+0"
85string(30) "                   0.000000e+0"
86string(4) "0-1]"
87string(1) "e"
88
89-- Iteration 3 --
90string(11) "0.000000e+0"
91string(1) "e"
92string(11) "0.000000e+0"
93string(1) "e"
94string(12) " 0.000000e+0"
95string(12) "0.000000e+0 "
96string(12) "	0.000000e+0"
97string(12) "
980.000000e+0"
99string(11) "0.000000e+0"
100string(30) "                   0.000000e+0"
101string(4) "0-1]"
102string(1) "e"
103
104-- Iteration 4 --
105string(11) "0.000000e+0"
106string(1) "e"
107string(11) "0.000000e+0"
108string(1) "e"
109string(12) " 0.000000e+0"
110string(12) "0.000000e+0 "
111string(12) "	0.000000e+0"
112string(12) "
1130.000000e+0"
114string(11) "0.000000e+0"
115string(30) "                   0.000000e+0"
116string(4) "0-1]"
117string(1) "e"
118
119-- Iteration 5 --
120string(11) "1.000000e+0"
121string(1) "e"
122string(11) "1.000000e+0"
123string(1) "e"
124string(12) " 1.000000e+0"
125string(12) "1.000000e+0 "
126string(12) "	1.000000e+0"
127string(12) "
1281.000000e+0"
129string(11) "1.000000e+0"
130string(30) "                   1.000000e+0"
131string(4) "0-1]"
132string(1) "e"
133
134-- Iteration 6 --
135string(11) "1.000000e+0"
136string(1) "e"
137string(11) "1.000000e+0"
138string(1) "e"
139string(12) " 1.000000e+0"
140string(12) "1.000000e+0 "
141string(12) "	1.000000e+0"
142string(12) "
1431.000000e+0"
144string(11) "1.000000e+0"
145string(30) "                   1.000000e+0"
146string(4) "0-1]"
147string(1) "e"
148
149-- Iteration 7 --
150string(11) "0.000000e+0"
151string(1) "e"
152string(11) "0.000000e+0"
153string(1) "e"
154string(12) " 0.000000e+0"
155string(12) "0.000000e+0 "
156string(12) "	0.000000e+0"
157string(12) "
1580.000000e+0"
159string(11) "0.000000e+0"
160string(30) "                   0.000000e+0"
161string(4) "0-1]"
162string(1) "e"
163
164-- Iteration 8 --
165string(11) "0.000000e+0"
166string(1) "e"
167string(11) "0.000000e+0"
168string(1) "e"
169string(12) " 0.000000e+0"
170string(12) "0.000000e+0 "
171string(12) "	0.000000e+0"
172string(12) "
1730.000000e+0"
174string(11) "0.000000e+0"
175string(30) "                   0.000000e+0"
176string(4) "0-1]"
177string(1) "e"
178
179-- Iteration 9 --
180string(11) "0.000000e+0"
181string(1) "e"
182string(11) "0.000000e+0"
183string(1) "e"
184string(12) " 0.000000e+0"
185string(12) "0.000000e+0 "
186string(12) "	0.000000e+0"
187string(12) "
1880.000000e+0"
189string(11) "0.000000e+0"
190string(30) "                   0.000000e+0"
191string(4) "0-1]"
192string(1) "e"
193
194-- Iteration 10 --
195string(11) "0.000000e+0"
196string(1) "e"
197string(11) "0.000000e+0"
198string(1) "e"
199string(12) " 0.000000e+0"
200string(12) "0.000000e+0 "
201string(12) "	0.000000e+0"
202string(12) "
2030.000000e+0"
204string(11) "0.000000e+0"
205string(30) "                   0.000000e+0"
206string(4) "0-1]"
207string(1) "e"
208
209-- Iteration 11 --
210string(11) "0.000000e+0"
211string(1) "e"
212string(11) "0.000000e+0"
213string(1) "e"
214string(12) " 0.000000e+0"
215string(12) "0.000000e+0 "
216string(12) "	0.000000e+0"
217string(12) "
2180.000000e+0"
219string(11) "0.000000e+0"
220string(30) "                   0.000000e+0"
221string(4) "0-1]"
222string(1) "e"
223
224-- Iteration 12 --
225string(11) "0.000000e+0"
226string(1) "e"
227string(11) "0.000000e+0"
228string(1) "e"
229string(12) " 0.000000e+0"
230string(12) "0.000000e+0 "
231string(12) "	0.000000e+0"
232string(12) "
2330.000000e+0"
234string(11) "0.000000e+0"
235string(30) "                   0.000000e+0"
236string(4) "0-1]"
237string(1) "e"
238
239-- Iteration 13 --
240string(11) "0.000000e+0"
241string(1) "e"
242string(11) "0.000000e+0"
243string(1) "e"
244string(12) " 0.000000e+0"
245string(12) "0.000000e+0 "
246string(12) "	0.000000e+0"
247string(12) "
2480.000000e+0"
249string(11) "0.000000e+0"
250string(30) "                   0.000000e+0"
251string(4) "0-1]"
252string(1) "e"
253
254-- Iteration 14 --
255string(11) "0.000000e+0"
256string(1) "e"
257string(11) "0.000000e+0"
258string(1) "e"
259string(12) " 0.000000e+0"
260string(12) "0.000000e+0 "
261string(12) "	0.000000e+0"
262string(12) "
2630.000000e+0"
264string(11) "0.000000e+0"
265string(30) "                   0.000000e+0"
266string(4) "0-1]"
267string(1) "e"
268
269-- Iteration 15 --
270string(11) "0.000000e+0"
271string(1) "e"
272string(11) "0.000000e+0"
273string(1) "e"
274string(12) " 0.000000e+0"
275string(12) "0.000000e+0 "
276string(12) "	0.000000e+0"
277string(12) "
2780.000000e+0"
279string(11) "0.000000e+0"
280string(30) "                   0.000000e+0"
281string(4) "0-1]"
282string(1) "e"
283
284-- Iteration 16 --
285string(11) "0.000000e+0"
286string(1) "e"
287string(11) "0.000000e+0"
288string(1) "e"
289string(12) " 0.000000e+0"
290string(12) "0.000000e+0 "
291string(12) "	0.000000e+0"
292string(12) "
2930.000000e+0"
294string(11) "0.000000e+0"
295string(30) "                   0.000000e+0"
296string(4) "0-1]"
297string(1) "e"
298
299-- Iteration 17 --
300string(11) "0.000000e+0"
301string(1) "e"
302string(11) "0.000000e+0"
303string(1) "e"
304string(12) " 0.000000e+0"
305string(12) "0.000000e+0 "
306string(12) "	0.000000e+0"
307string(12) "
3080.000000e+0"
309string(11) "0.000000e+0"
310string(30) "                   0.000000e+0"
311string(4) "0-1]"
312string(1) "e"
313
314-- Iteration 18 --
315string(11) "0.000000e+0"
316string(1) "e"
317string(11) "0.000000e+0"
318string(1) "e"
319string(12) " 0.000000e+0"
320string(12) "0.000000e+0 "
321string(12) "	0.000000e+0"
322string(12) "
3230.000000e+0"
324string(11) "0.000000e+0"
325string(30) "                   0.000000e+0"
326string(4) "0-1]"
327string(1) "e"
328
329-- Iteration 19 --
330string(12) "3.333333e+29"
331string(1) "e"
332string(12) "3.333333e+29"
333string(1) "e"
334string(13) " 3.333333e+29"
335string(13) "3.333333e+29 "
336string(13) "	3.333333e+29"
337string(13) "
3383.333333e+29"
339string(12) "3.333333e+29"
340string(30) "                  3.333333e+29"
341string(4) "0-1]"
342string(1) "e"
343Done
344