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