1--TEST--
2Test pathinfo() function: basic functionality
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) == "WIN")
8  die("skip Not valid for Windows");
9?>
10--FILE--
11<?php
12echo "*** Testing basic functions of pathinfo() ***\n";
13
14$paths = array (
15                '',
16            ' ',
17            'c:',
18            'c:\\',
19            'c:/',
20            'afile',
21            'c:\test\adir',
22            'c:\test\adir\\',
23            '/usr/include/arpa',
24            '/usr/include/arpa/',
25            'usr/include/arpa',
26            'usr/include/arpa/',
27            'c:\test\afile',
28            'c:\\test\\afile',
29            'c://test//afile',
30            'c:\test\afile\\',
31            'c:\test\prog.exe',
32            'c:\\test\\prog.exe',
33            'c:/test/prog.exe',
34            '/usr/include/arpa/inet.h',
35            '//usr/include//arpa/inet.h',
36            '\\',
37            '\\\\',
38            '/',
39            '//',
40            '///',
41            '/usr/include/arpa/inet.h',
42            'c:\windows/system32\drivers/etc\hosts',
43            '/usr\include/arpa\inet.h',
44            '   c:\test\adir\afile.txt',
45            'c:\test\adir\afile.txt   ',
46            '   c:\test\adir\afile.txt   ',
47            '   /usr/include/arpa/inet.h',
48            '/usr/include/arpa/inet.h   ',
49            '   /usr/include/arpa/inet.h   ',
50            ' c:',
51            '		c:\test\adir\afile.txt',
52            '/usr',
53            '/usr/'
54);
55
56$counter = 1;
57/* loop through $paths to test each $path in the above array */
58foreach($paths as $path) {
59  echo "-- Iteration $counter --\n";
60  var_dump( pathinfo($path, PATHINFO_DIRNAME) );
61  var_dump( pathinfo($path, PATHINFO_BASENAME) );
62  var_dump( pathinfo($path, PATHINFO_EXTENSION) );
63  var_dump( pathinfo($path, PATHINFO_FILENAME) );
64  var_dump( pathinfo($path) );
65  $counter++;
66}
67
68echo "Done\n";
69?>
70--EXPECT--
71*** Testing basic functions of pathinfo() ***
72-- Iteration 1 --
73string(0) ""
74string(0) ""
75string(0) ""
76string(0) ""
77array(2) {
78  ["basename"]=>
79  string(0) ""
80  ["filename"]=>
81  string(0) ""
82}
83-- Iteration 2 --
84string(1) "."
85string(1) " "
86string(0) ""
87string(1) " "
88array(3) {
89  ["dirname"]=>
90  string(1) "."
91  ["basename"]=>
92  string(1) " "
93  ["filename"]=>
94  string(1) " "
95}
96-- Iteration 3 --
97string(1) "."
98string(2) "c:"
99string(0) ""
100string(2) "c:"
101array(3) {
102  ["dirname"]=>
103  string(1) "."
104  ["basename"]=>
105  string(2) "c:"
106  ["filename"]=>
107  string(2) "c:"
108}
109-- Iteration 4 --
110string(1) "."
111string(3) "c:\"
112string(0) ""
113string(3) "c:\"
114array(3) {
115  ["dirname"]=>
116  string(1) "."
117  ["basename"]=>
118  string(3) "c:\"
119  ["filename"]=>
120  string(3) "c:\"
121}
122-- Iteration 5 --
123string(1) "."
124string(2) "c:"
125string(0) ""
126string(2) "c:"
127array(3) {
128  ["dirname"]=>
129  string(1) "."
130  ["basename"]=>
131  string(2) "c:"
132  ["filename"]=>
133  string(2) "c:"
134}
135-- Iteration 6 --
136string(1) "."
137string(5) "afile"
138string(0) ""
139string(5) "afile"
140array(3) {
141  ["dirname"]=>
142  string(1) "."
143  ["basename"]=>
144  string(5) "afile"
145  ["filename"]=>
146  string(5) "afile"
147}
148-- Iteration 7 --
149string(1) "."
150string(12) "c:\test\adir"
151string(0) ""
152string(12) "c:\test\adir"
153array(3) {
154  ["dirname"]=>
155  string(1) "."
156  ["basename"]=>
157  string(12) "c:\test\adir"
158  ["filename"]=>
159  string(12) "c:\test\adir"
160}
161-- Iteration 8 --
162string(1) "."
163string(13) "c:\test\adir\"
164string(0) ""
165string(13) "c:\test\adir\"
166array(3) {
167  ["dirname"]=>
168  string(1) "."
169  ["basename"]=>
170  string(13) "c:\test\adir\"
171  ["filename"]=>
172  string(13) "c:\test\adir\"
173}
174-- Iteration 9 --
175string(12) "/usr/include"
176string(4) "arpa"
177string(0) ""
178string(4) "arpa"
179array(3) {
180  ["dirname"]=>
181  string(12) "/usr/include"
182  ["basename"]=>
183  string(4) "arpa"
184  ["filename"]=>
185  string(4) "arpa"
186}
187-- Iteration 10 --
188string(12) "/usr/include"
189string(4) "arpa"
190string(0) ""
191string(4) "arpa"
192array(3) {
193  ["dirname"]=>
194  string(12) "/usr/include"
195  ["basename"]=>
196  string(4) "arpa"
197  ["filename"]=>
198  string(4) "arpa"
199}
200-- Iteration 11 --
201string(11) "usr/include"
202string(4) "arpa"
203string(0) ""
204string(4) "arpa"
205array(3) {
206  ["dirname"]=>
207  string(11) "usr/include"
208  ["basename"]=>
209  string(4) "arpa"
210  ["filename"]=>
211  string(4) "arpa"
212}
213-- Iteration 12 --
214string(11) "usr/include"
215string(4) "arpa"
216string(0) ""
217string(4) "arpa"
218array(3) {
219  ["dirname"]=>
220  string(11) "usr/include"
221  ["basename"]=>
222  string(4) "arpa"
223  ["filename"]=>
224  string(4) "arpa"
225}
226-- Iteration 13 --
227string(1) "."
228string(13) "c:\test\afile"
229string(0) ""
230string(13) "c:\test\afile"
231array(3) {
232  ["dirname"]=>
233  string(1) "."
234  ["basename"]=>
235  string(13) "c:\test\afile"
236  ["filename"]=>
237  string(13) "c:\test\afile"
238}
239-- Iteration 14 --
240string(1) "."
241string(13) "c:\test\afile"
242string(0) ""
243string(13) "c:\test\afile"
244array(3) {
245  ["dirname"]=>
246  string(1) "."
247  ["basename"]=>
248  string(13) "c:\test\afile"
249  ["filename"]=>
250  string(13) "c:\test\afile"
251}
252-- Iteration 15 --
253string(8) "c://test"
254string(5) "afile"
255string(0) ""
256string(5) "afile"
257array(3) {
258  ["dirname"]=>
259  string(8) "c://test"
260  ["basename"]=>
261  string(5) "afile"
262  ["filename"]=>
263  string(5) "afile"
264}
265-- Iteration 16 --
266string(1) "."
267string(14) "c:\test\afile\"
268string(0) ""
269string(14) "c:\test\afile\"
270array(3) {
271  ["dirname"]=>
272  string(1) "."
273  ["basename"]=>
274  string(14) "c:\test\afile\"
275  ["filename"]=>
276  string(14) "c:\test\afile\"
277}
278-- Iteration 17 --
279string(1) "."
280string(16) "c:\test\prog.exe"
281string(3) "exe"
282string(12) "c:\test\prog"
283array(4) {
284  ["dirname"]=>
285  string(1) "."
286  ["basename"]=>
287  string(16) "c:\test\prog.exe"
288  ["extension"]=>
289  string(3) "exe"
290  ["filename"]=>
291  string(12) "c:\test\prog"
292}
293-- Iteration 18 --
294string(1) "."
295string(16) "c:\test\prog.exe"
296string(3) "exe"
297string(12) "c:\test\prog"
298array(4) {
299  ["dirname"]=>
300  string(1) "."
301  ["basename"]=>
302  string(16) "c:\test\prog.exe"
303  ["extension"]=>
304  string(3) "exe"
305  ["filename"]=>
306  string(12) "c:\test\prog"
307}
308-- Iteration 19 --
309string(7) "c:/test"
310string(8) "prog.exe"
311string(3) "exe"
312string(4) "prog"
313array(4) {
314  ["dirname"]=>
315  string(7) "c:/test"
316  ["basename"]=>
317  string(8) "prog.exe"
318  ["extension"]=>
319  string(3) "exe"
320  ["filename"]=>
321  string(4) "prog"
322}
323-- Iteration 20 --
324string(17) "/usr/include/arpa"
325string(6) "inet.h"
326string(1) "h"
327string(4) "inet"
328array(4) {
329  ["dirname"]=>
330  string(17) "/usr/include/arpa"
331  ["basename"]=>
332  string(6) "inet.h"
333  ["extension"]=>
334  string(1) "h"
335  ["filename"]=>
336  string(4) "inet"
337}
338-- Iteration 21 --
339string(19) "//usr/include//arpa"
340string(6) "inet.h"
341string(1) "h"
342string(4) "inet"
343array(4) {
344  ["dirname"]=>
345  string(19) "//usr/include//arpa"
346  ["basename"]=>
347  string(6) "inet.h"
348  ["extension"]=>
349  string(1) "h"
350  ["filename"]=>
351  string(4) "inet"
352}
353-- Iteration 22 --
354string(1) "."
355string(1) "\"
356string(0) ""
357string(1) "\"
358array(3) {
359  ["dirname"]=>
360  string(1) "."
361  ["basename"]=>
362  string(1) "\"
363  ["filename"]=>
364  string(1) "\"
365}
366-- Iteration 23 --
367string(1) "."
368string(2) "\\"
369string(0) ""
370string(2) "\\"
371array(3) {
372  ["dirname"]=>
373  string(1) "."
374  ["basename"]=>
375  string(2) "\\"
376  ["filename"]=>
377  string(2) "\\"
378}
379-- Iteration 24 --
380string(1) "/"
381string(0) ""
382string(0) ""
383string(0) ""
384array(3) {
385  ["dirname"]=>
386  string(1) "/"
387  ["basename"]=>
388  string(0) ""
389  ["filename"]=>
390  string(0) ""
391}
392-- Iteration 25 --
393string(1) "/"
394string(0) ""
395string(0) ""
396string(0) ""
397array(3) {
398  ["dirname"]=>
399  string(1) "/"
400  ["basename"]=>
401  string(0) ""
402  ["filename"]=>
403  string(0) ""
404}
405-- Iteration 26 --
406string(1) "/"
407string(0) ""
408string(0) ""
409string(0) ""
410array(3) {
411  ["dirname"]=>
412  string(1) "/"
413  ["basename"]=>
414  string(0) ""
415  ["filename"]=>
416  string(0) ""
417}
418-- Iteration 27 --
419string(17) "/usr/include/arpa"
420string(6) "inet.h"
421string(1) "h"
422string(4) "inet"
423array(4) {
424  ["dirname"]=>
425  string(17) "/usr/include/arpa"
426  ["basename"]=>
427  string(6) "inet.h"
428  ["extension"]=>
429  string(1) "h"
430  ["filename"]=>
431  string(4) "inet"
432}
433-- Iteration 28 --
434string(27) "c:\windows/system32\drivers"
435string(9) "etc\hosts"
436string(0) ""
437string(9) "etc\hosts"
438array(3) {
439  ["dirname"]=>
440  string(27) "c:\windows/system32\drivers"
441  ["basename"]=>
442  string(9) "etc\hosts"
443  ["filename"]=>
444  string(9) "etc\hosts"
445}
446-- Iteration 29 --
447string(12) "/usr\include"
448string(11) "arpa\inet.h"
449string(1) "h"
450string(9) "arpa\inet"
451array(4) {
452  ["dirname"]=>
453  string(12) "/usr\include"
454  ["basename"]=>
455  string(11) "arpa\inet.h"
456  ["extension"]=>
457  string(1) "h"
458  ["filename"]=>
459  string(9) "arpa\inet"
460}
461-- Iteration 30 --
462string(1) "."
463string(25) "   c:\test\adir\afile.txt"
464string(3) "txt"
465string(21) "   c:\test\adir\afile"
466array(4) {
467  ["dirname"]=>
468  string(1) "."
469  ["basename"]=>
470  string(25) "   c:\test\adir\afile.txt"
471  ["extension"]=>
472  string(3) "txt"
473  ["filename"]=>
474  string(21) "   c:\test\adir\afile"
475}
476-- Iteration 31 --
477string(1) "."
478string(25) "c:\test\adir\afile.txt   "
479string(6) "txt   "
480string(18) "c:\test\adir\afile"
481array(4) {
482  ["dirname"]=>
483  string(1) "."
484  ["basename"]=>
485  string(25) "c:\test\adir\afile.txt   "
486  ["extension"]=>
487  string(6) "txt   "
488  ["filename"]=>
489  string(18) "c:\test\adir\afile"
490}
491-- Iteration 32 --
492string(1) "."
493string(28) "   c:\test\adir\afile.txt   "
494string(6) "txt   "
495string(21) "   c:\test\adir\afile"
496array(4) {
497  ["dirname"]=>
498  string(1) "."
499  ["basename"]=>
500  string(28) "   c:\test\adir\afile.txt   "
501  ["extension"]=>
502  string(6) "txt   "
503  ["filename"]=>
504  string(21) "   c:\test\adir\afile"
505}
506-- Iteration 33 --
507string(20) "   /usr/include/arpa"
508string(6) "inet.h"
509string(1) "h"
510string(4) "inet"
511array(4) {
512  ["dirname"]=>
513  string(20) "   /usr/include/arpa"
514  ["basename"]=>
515  string(6) "inet.h"
516  ["extension"]=>
517  string(1) "h"
518  ["filename"]=>
519  string(4) "inet"
520}
521-- Iteration 34 --
522string(17) "/usr/include/arpa"
523string(9) "inet.h   "
524string(4) "h   "
525string(4) "inet"
526array(4) {
527  ["dirname"]=>
528  string(17) "/usr/include/arpa"
529  ["basename"]=>
530  string(9) "inet.h   "
531  ["extension"]=>
532  string(4) "h   "
533  ["filename"]=>
534  string(4) "inet"
535}
536-- Iteration 35 --
537string(20) "   /usr/include/arpa"
538string(9) "inet.h   "
539string(4) "h   "
540string(4) "inet"
541array(4) {
542  ["dirname"]=>
543  string(20) "   /usr/include/arpa"
544  ["basename"]=>
545  string(9) "inet.h   "
546  ["extension"]=>
547  string(4) "h   "
548  ["filename"]=>
549  string(4) "inet"
550}
551-- Iteration 36 --
552string(1) "."
553string(3) " c:"
554string(0) ""
555string(3) " c:"
556array(3) {
557  ["dirname"]=>
558  string(1) "."
559  ["basename"]=>
560  string(3) " c:"
561  ["filename"]=>
562  string(3) " c:"
563}
564-- Iteration 37 --
565string(1) "."
566string(24) "		c:\test\adir\afile.txt"
567string(3) "txt"
568string(20) "		c:\test\adir\afile"
569array(4) {
570  ["dirname"]=>
571  string(1) "."
572  ["basename"]=>
573  string(24) "		c:\test\adir\afile.txt"
574  ["extension"]=>
575  string(3) "txt"
576  ["filename"]=>
577  string(20) "		c:\test\adir\afile"
578}
579-- Iteration 38 --
580string(1) "/"
581string(3) "usr"
582string(0) ""
583string(3) "usr"
584array(3) {
585  ["dirname"]=>
586  string(1) "/"
587  ["basename"]=>
588  string(3) "usr"
589  ["filename"]=>
590  string(3) "usr"
591}
592-- Iteration 39 --
593string(1) "/"
594string(3) "usr"
595string(0) ""
596string(3) "usr"
597array(3) {
598  ["dirname"]=>
599  string(1) "/"
600  ["basename"]=>
601  string(3) "usr"
602  ["filename"]=>
603  string(3) "usr"
604}
605Done
606