Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation22.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - char formats with float 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:
10: echo "*** Testing sprintf() : char formats with float values ***\n";
11:
12: // array of float values
13: $float_values = array(
14: 0.0,
15: -0.1,
16: 1.0,
17: 1e5,
18: -1e6,
19: 1E8,
20: -1E9,
21: 10.5e+5
22: );
23:
24: // array of char formats
25: $char_formats = array(
26: "%c", "%hc", "%lc",
27: "%Lc", " %c", "%c ",
28: "\t%c", "\n%c", "%4c",
29: "%30c", "%[a-bA-B@#$&]", "%*c"
30: );
31:
32: $count = 1;
33: foreach($float_values as $float_value) {
34: echo "\n-- Iteration $count --\n";
35:
36: foreach($char_formats as $format) {
37: var_dump( sprintf($format, $float_value) );
38: }
39: $count++;
40: };
41:
42: echo "Done";
43: ?>
44: --EXPECTF--
45: *** Testing sprintf() : char formats with float values ***
46:
47: -- Iteration 1 --
48: string(1) "