Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation25.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - char 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:
10: echo "*** Testing sprintf() : char 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: );
33:
34: // array of char formats
35: $char_formats = array(
36: "%c", "%hc", "%lc",
37: "%Lc", " %c", "%c ",
38: "\t%c", "\n%c", "%4c",
39: "%30c", "%[a-bA-B@#$&]", "%*c"
40: );
41:
42: $count = 1;
43: foreach($string_values as $string_value) {
44: echo "\n-- Iteration $count --\n";
45:
46: foreach($char_formats as $format) {
47: var_dump( sprintf($format, $string_value) );
48: }
49: $count++;
50: };
51:
52: echo "Done";
53: ?>
54: --EXPECTF--
55: *** Testing sprintf() : char formats with string values ***
56:
57: -- Iteration 1 --
58: string(1) "