Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation23.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - char formats with resource 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 resource values ***\n";
11:
12: // resource type variable
13: $fp = fopen (__FILE__, "r");
14: $dfp = opendir ( dirname(__FILE__) );
15:
16: // array of resource types
17: $resource_values = array (
18: $fp,
19: $dfp
20: );
21:
22: // array of char formats
23: $char_formats = array(
24: "%c", "%hc", "%lc",
25: "%Lc", " %c", "%c ",
26: "\t%c", "\n%c", "%4c",
27: "%30c", "%[a-bA-B@#$&]", "%*c"
28: );
29:
30: $count = 1;
31: foreach($resource_values as $resource_value) {
32: echo "\n-- Iteration $count --\n";
33:
34: foreach($char_formats as $format) {
35: var_dump( sprintf($format, $resource_value) );
36: }
37: $count++;
38: };
39:
40: // closing the resources
41: fclose($fp);
42: closedir($dfp);
43:
44: ?>
45: ===DONE===
46: --EXPECTF--
47: *** Testing sprintf() : char formats with resource values ***
48:
49: -- Iteration 1 --
50: string(1) "%a"
51: string(1) "c"
52: string(1) "%a"
53: string(1) "c"
54: string(2) " %a"
55: string(2) "%a "
56: string(2) " %a"
57: string(2) "
58: %a"
59: string(1) "%a"
60: string(1) "%a"
61: string(11) "a-bA-B@#$&]"
62: string(1) "c"
63:
64: -- Iteration 2 --
65: string(1) "%a"
66: string(1) "%a"
67: string(1) "%a"
68: string(1) "c"
69: string(2) " %a"
70: string(2) "%a "
71: string(2) " %a"
72: string(2) "
73: %a"
74: string(1) "%a"
75: string(1) "%a"
76: string(11) "a-bA-B@#$&]"
77: string(1) "c"
78: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>