Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / standard / tests / file / fscanf_variation41.phpt
blob080ce98054d464b2800e5d2f2049fe1aed3e4420
1 --TEST--
2 Test fscanf() function: usage variations - unsigned formats with resource 
3 --FILE--
4 <?php
6 /*
7   Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
8   Description: Parses input from a file according to a format
9 */
11 /* Test fscanf() to scan resource type using different unsigned format types */
13 $file_path = dirname(__FILE__);
15 echo "*** Test fscanf(): different unsigned format types with resource ***\n"; 
17 // create a file
18 $filename = "$file_path/fscanf_variation41.tmp";
19 $file_handle = fopen($filename, "w");
20 if($file_handle == false)
21   exit("Error:failed to open file $filename");
24 // resource type variable
25 $fp = fopen (__FILE__, "r");
26 $dfp = opendir ( dirname(__FILE__) );
27   
28 // array of resource types
29 $resource_types = array (
30   $fp,
31   $dfp
34 $unsigned_formats = array( "%u", "%hu", "%lu", "%Lu", " %u", "%u ", "% u", "\t%u", "\n%u", "%4u", "%30u", "%[0-9]", "%*u");
36 $counter = 1;
38 // writing to the file
39 foreach($resource_types as $value) {
40   @fprintf($file_handle, $value);
41   @fprintf($file_handle, "\n");
43 // closing the file
44 fclose($file_handle);
46 // opening the file for reading
47 $file_handle = fopen($filename, "r");
48 if($file_handle == false) {
49   exit("Error:failed to open file $filename");
52 $counter = 1;
53 // reading the values from file using different unsigned formats
54 foreach($unsigned_formats as $unsigned_format) {
55   // rewind the file so that for every foreach iteration the file pointer starts from bof
56   rewind($file_handle);
57   echo "\n-- iteration $counter --\n";
58   while( !feof($file_handle) ) {
59     var_dump( fscanf($file_handle,$unsigned_format) );
60   }
61   $counter++;
64 // closing the resources
65 fclose($fp);
66 closedir($dfp);
68 echo "\n*** Done ***";
70 --CLEAN--
71 <?php
72 $file_path = dirname(__FILE__);
73 $filename = "$file_path/fscanf_variation41.tmp";
74 unlink($filename);
76 --EXPECTF--
77 *** Test fscanf(): different unsigned format types with resource ***
79 -- iteration 1 --
80 array(1) {
81   [0]=>
82   NULL
84 array(1) {
85   [0]=>
86   NULL
88 bool(false)
90 -- iteration 2 --
91 array(1) {
92   [0]=>
93   NULL
95 array(1) {
96   [0]=>
97   NULL
99 bool(false)
101 -- iteration 3 --
102 array(1) {
103   [0]=>
104   NULL
106 array(1) {
107   [0]=>
108   NULL
110 bool(false)
112 -- iteration 4 --
113 array(1) {
114   [0]=>
115   NULL
117 array(1) {
118   [0]=>
119   NULL
121 bool(false)
123 -- iteration 5 --
124 array(1) {
125   [0]=>
126   NULL
128 array(1) {
129   [0]=>
130   NULL
132 bool(false)
134 -- iteration 6 --
135 array(1) {
136   [0]=>
137   NULL
139 array(1) {
140   [0]=>
141   NULL
143 bool(false)
145 -- iteration 7 --
147 Warning: fscanf(): Bad scan conversion character " " in %s on line %d
148 NULL
150 Warning: fscanf(): Bad scan conversion character " " in %s on line %d
151 NULL
152 bool(false)
154 -- iteration 8 --
155 array(1) {
156   [0]=>
157   NULL
159 array(1) {
160   [0]=>
161   NULL
163 bool(false)
165 -- iteration 9 --
166 array(1) {
167   [0]=>
168   NULL
170 array(1) {
171   [0]=>
172   NULL
174 bool(false)
176 -- iteration 10 --
177 array(1) {
178   [0]=>
179   NULL
181 array(1) {
182   [0]=>
183   NULL
185 bool(false)
187 -- iteration 11 --
188 array(1) {
189   [0]=>
190   NULL
192 array(1) {
193   [0]=>
194   NULL
196 bool(false)
198 -- iteration 12 --
199 array(1) {
200   [0]=>
201   NULL
203 array(1) {
204   [0]=>
205   NULL
207 bool(false)
209 -- iteration 13 --
210 array(0) {
212 array(0) {
214 bool(false)
216 *** Done ***