1--TEST--
2Test lstat() and stat() functions: usage variations - dir/file names in array
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip.. Not valid for Windows');
7}
8?>
9--FILE--
10<?php
11/* Prototype: array lstat ( string $filename );
12   Description: Gives information about a file or symbolic link
13
14   Prototype: array stat ( string $filename );
15   Description: Gives information about a file
16*/
17
18/* test for stats of dir/file when their names are stored in an array */
19
20$file_path = dirname(__FILE__);
21require "$file_path/file.inc";
22
23
24/* create temp file, link and directory */
25@rmdir("$file_path/lstat_stat_variation19");  // ensure that dir doesn't exists
26mkdir("$file_path/lstat_stat_variation19");  // temp dir
27
28$fp = fopen("$file_path/lstat_stat_variation19.tmp", "w");  // temp file
29fclose($fp);
30
31echo "*** Testing stat() with filename & directory name stored inside an array ***\n";
32
33// array with default numeric index
34$names = array(
35  "$file_path/lstat_stat_variation19.tmp",
36  "$file_path/lstat_stat_variation19"
37);
38
39//array with string key index
40$names_with_key = array (
41  'file' => "$file_path/lstat_stat_variation19.tmp",
42  "dir" => "$file_path/lstat_stat_variation19"
43);
44
45echo "\n-- Testing stat() on filename stored inside an array --\n";
46var_dump( stat($names[0]) ); // values stored with numeric index
47var_dump( stat($names_with_key['file']) ); // value stored with string key
48
49echo "\n-- Testing stat() on dir name stored inside an array --\n";
50var_dump( stat($names[1]) ); // values stored with numeric index
51var_dump( stat($names_with_key["dir"]) ); // value stored with string key
52
53echo "\n--- Done ---";
54?>
55
56--CLEAN--
57<?php
58$file_path = dirname(__FILE__);
59unlink("$file_path/lstat_stat_variation19.tmp");
60rmdir("$file_path/lstat_stat_variation19");
61?>
62--EXPECTF--
63*** Testing stat() with filename & directory name stored inside an array ***
64
65-- Testing stat() on filename stored inside an array --
66array(26) {
67  [0]=>
68  int(%d)
69  [1]=>
70  int(%d)
71  [2]=>
72  int(%d)
73  [3]=>
74  int(%d)
75  [4]=>
76  int(%d)
77  [5]=>
78  int(%d)
79  [6]=>
80  int(%d)
81  [7]=>
82  int(%d)
83  [8]=>
84  int(%d)
85  [9]=>
86  int(%d)
87  [10]=>
88  int(%d)
89  [11]=>
90  int(%d)
91  [12]=>
92  int(%d)
93  ["dev"]=>
94  int(%d)
95  ["ino"]=>
96  int(%d)
97  ["mode"]=>
98  int(%d)
99  ["nlink"]=>
100  int(%d)
101  ["uid"]=>
102  int(%d)
103  ["gid"]=>
104  int(%d)
105  ["rdev"]=>
106  int(%d)
107  ["size"]=>
108  int(%d)
109  ["atime"]=>
110  int(%d)
111  ["mtime"]=>
112  int(%d)
113  ["ctime"]=>
114  int(%d)
115  ["blksize"]=>
116  int(%d)
117  ["blocks"]=>
118  int(%d)
119}
120array(26) {
121  [0]=>
122  int(%d)
123  [1]=>
124  int(%d)
125  [2]=>
126  int(%d)
127  [3]=>
128  int(%d)
129  [4]=>
130  int(%d)
131  [5]=>
132  int(%d)
133  [6]=>
134  int(%d)
135  [7]=>
136  int(%d)
137  [8]=>
138  int(%d)
139  [9]=>
140  int(%d)
141  [10]=>
142  int(%d)
143  [11]=>
144  int(%d)
145  [12]=>
146  int(%d)
147  ["dev"]=>
148  int(%d)
149  ["ino"]=>
150  int(%d)
151  ["mode"]=>
152  int(%d)
153  ["nlink"]=>
154  int(%d)
155  ["uid"]=>
156  int(%d)
157  ["gid"]=>
158  int(%d)
159  ["rdev"]=>
160  int(%d)
161  ["size"]=>
162  int(%d)
163  ["atime"]=>
164  int(%d)
165  ["mtime"]=>
166  int(%d)
167  ["ctime"]=>
168  int(%d)
169  ["blksize"]=>
170  int(%d)
171  ["blocks"]=>
172  int(%d)
173}
174
175-- Testing stat() on dir name stored inside an array --
176array(26) {
177  [0]=>
178  int(%d)
179  [1]=>
180  int(%d)
181  [2]=>
182  int(%d)
183  [3]=>
184  int(%d)
185  [4]=>
186  int(%d)
187  [5]=>
188  int(%d)
189  [6]=>
190  int(%d)
191  [7]=>
192  int(%d)
193  [8]=>
194  int(%d)
195  [9]=>
196  int(%d)
197  [10]=>
198  int(%d)
199  [11]=>
200  int(%d)
201  [12]=>
202  int(%d)
203  ["dev"]=>
204  int(%d)
205  ["ino"]=>
206  int(%d)
207  ["mode"]=>
208  int(%d)
209  ["nlink"]=>
210  int(%d)
211  ["uid"]=>
212  int(%d)
213  ["gid"]=>
214  int(%d)
215  ["rdev"]=>
216  int(%d)
217  ["size"]=>
218  int(%d)
219  ["atime"]=>
220  int(%d)
221  ["mtime"]=>
222  int(%d)
223  ["ctime"]=>
224  int(%d)
225  ["blksize"]=>
226  int(%d)
227  ["blocks"]=>
228  int(%d)
229}
230array(26) {
231  [0]=>
232  int(%d)
233  [1]=>
234  int(%d)
235  [2]=>
236  int(%d)
237  [3]=>
238  int(%d)
239  [4]=>
240  int(%d)
241  [5]=>
242  int(%d)
243  [6]=>
244  int(%d)
245  [7]=>
246  int(%d)
247  [8]=>
248  int(%d)
249  [9]=>
250  int(%d)
251  [10]=>
252  int(%d)
253  [11]=>
254  int(%d)
255  [12]=>
256  int(%d)
257  ["dev"]=>
258  int(%d)
259  ["ino"]=>
260  int(%d)
261  ["mode"]=>
262  int(%d)
263  ["nlink"]=>
264  int(%d)
265  ["uid"]=>
266  int(%d)
267  ["gid"]=>
268  int(%d)
269  ["rdev"]=>
270  int(%d)
271  ["size"]=>
272  int(%d)
273  ["atime"]=>
274  int(%d)
275  ["mtime"]=>
276  int(%d)
277  ["ctime"]=>
278  int(%d)
279  ["blksize"]=>
280  int(%d)
281  ["blocks"]=>
282  int(%d)
283}
284
285--- Done ---
286