Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation27.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - char formats with char 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:
11: echo "*** Testing sprintf() : char formats with char values ***\n";
12:
13: // array of char values
14: $char_values = array( 'a', "a", 67, -67, 99, ' ', '', 'A', "A" );
15:
16: // array of char formats
17: $char_formats = array(
18: "%c", "%hc", "%lc",
19: "%Lc", " %c", "%c ",
20: "\t%c", "\n%c", "%4c",
21: "%30c", "%[a-bA-B@#$&]", "%*c"
22: );
23:
24: $count = 1;
25: foreach($char_values as $char_value) {
26: echo "\n-- Iteration $count --\n";
27:
28: foreach($char_formats as $format) {
29: var_dump( sprintf($format, $char_value) );
30: }
31: $count++;
32: };
33:
34: echo "Done";
35: ?>
36: --EXPECTF--
37: *** Testing sprintf() : char formats with char values ***
38:
39: -- Iteration 1 --
40: string(1) "