Annotation of embedaddon/php/ext/standard/tests/file/fscanf_variation52.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fscanf() function: usage variations - empty file
3: --FILE--
4: <?php
5:
6: /*
7: Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
8: Description: Parses input from a file according to a format
9: */
10:
11: /* Test fscanf() to scan an empty file */
12:
13: $file_path = dirname(__FILE__);
14:
15: echo "*** Test fscanf(): to read an empty file ***\n";
16:
17: // various formats
18: $formats = array( "%d", "%f", "%e", "%u", " %s", "%x", "%o");
19:
20: $counter = 1;
21:
22: // various read modes
23: $modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
24: "w+", "w+b", "w+t",
25: "a+", "a+b", "a+t"
26: );
27:
28: $counter = 1;
29: // reading the values from file using different integer formats
30: foreach($modes as $mode) {
31:
32: // create an empty file
33: $filename = "$file_path/fscanf_variation52.tmp";
34: $file_handle = fopen($filename, "w");
35: if($file_handle == false)
36: exit("Error:failed to open file $filename");
37: //closing the file
38: fclose($file_handle);
39:
40: // opening file in $mode mode
41: $file_handle = fopen($filename, $mode);
42: if($file_handle == false) {
43: exit("Error:failed to open file $filename");
44: }
45: echo "\n-- iteration $counter --\n";
46:
47: foreach($formats as $format) {
48: var_dump( fscanf($file_handle,$format) );
49: rewind($file_handle);
50: }
51: $counter++;
52: fclose($file_handle);
53: unlink($filename);
54: }
55:
56: echo "\n*** Done ***";
57: ?>
58: --CLEAN--
59: <?php
60: $file_path = dirname(__FILE__);
61: $filename = "$file_path/fscanf_variation52.tmp";
62: if(file_exists($filename)) {
63: unlink($filename);
64: }
65: ?>
66: --EXPECT--
67: *** Test fscanf(): to read an empty file ***
68:
69: -- iteration 1 --
70: bool(false)
71: bool(false)
72: bool(false)
73: bool(false)
74: bool(false)
75: bool(false)
76: bool(false)
77:
78: -- iteration 2 --
79: bool(false)
80: bool(false)
81: bool(false)
82: bool(false)
83: bool(false)
84: bool(false)
85: bool(false)
86:
87: -- iteration 3 --
88: bool(false)
89: bool(false)
90: bool(false)
91: bool(false)
92: bool(false)
93: bool(false)
94: bool(false)
95:
96: -- iteration 4 --
97: bool(false)
98: bool(false)
99: bool(false)
100: bool(false)
101: bool(false)
102: bool(false)
103: bool(false)
104:
105: -- iteration 5 --
106: bool(false)
107: bool(false)
108: bool(false)
109: bool(false)
110: bool(false)
111: bool(false)
112: bool(false)
113:
114: -- iteration 6 --
115: bool(false)
116: bool(false)
117: bool(false)
118: bool(false)
119: bool(false)
120: bool(false)
121: bool(false)
122:
123: -- iteration 7 --
124: bool(false)
125: bool(false)
126: bool(false)
127: bool(false)
128: bool(false)
129: bool(false)
130: bool(false)
131:
132: -- iteration 8 --
133: bool(false)
134: bool(false)
135: bool(false)
136: bool(false)
137: bool(false)
138: bool(false)
139: bool(false)
140:
141: -- iteration 9 --
142: bool(false)
143: bool(false)
144: bool(false)
145: bool(false)
146: bool(false)
147: bool(false)
148: bool(false)
149:
150: -- iteration 10 --
151: bool(false)
152: bool(false)
153: bool(false)
154: bool(false)
155: bool(false)
156: bool(false)
157: bool(false)
158:
159: -- iteration 11 --
160: bool(false)
161: bool(false)
162: bool(false)
163: bool(false)
164: bool(false)
165: bool(false)
166: bool(false)
167:
168: -- iteration 12 --
169: bool(false)
170: bool(false)
171: bool(false)
172: bool(false)
173: bool(false)
174: bool(false)
175: bool(false)
176:
177: *** Done ***
178:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>