Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation48.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - scientific 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() : scientific 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 scientific formats
23: $scientific_formats = array(
24: "%e", "%he", "%le",
25: "%Le", " %e", "%e ",
26: "\t%e", "\n%e", "%4e",
27: "%30e", "%[0-1]", "%*e"
28: );
29:
30: $count = 1;
31: foreach($resource_values as $resource_value) {
32: echo "\n-- Iteration $count --\n";
33:
34: foreach($scientific_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() : scientific formats with resource values ***
48:
49: -- Iteration 1 --
50: string(%d) "%f"
51: string(1) "e"
52: string(%d) "%f"
53: string(1) "e"
54: string(%d) " %f"
55: string(%d) "%f "
56: string(%d) " %f"
57: string(%d) "
58: %f"
59: string(%d) "%f"
60: string(30) "%s%f"
61: string(%d) "0-1]"
62: string(1) "e"
63:
64: -- Iteration 2 --
65: string(%d) "%f"
66: string(1) "e"
67: string(%d) "%f"
68: string(1) "e"
69: string(%d) " %f"
70: string(%d) "%f "
71: string(%d) " %f"
72: string(%d) "
73: %f"
74: string(%d) "%f"
75: string(30) "%s%f"
76: string(%d) "0-1]"
77: string(1) "e"
78: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>