123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605 |
- --TEST--
- Test pathinfo() function: basic functionality
- --CREDITS--
- Dave Kelsey <d_kelsey@uk.ibm.com>
- --SKIPIF--
- <?php
- if(substr(PHP_OS, 0, 3) != "WIN")
- die("skip Only valid for Windows");
- ?>
- --FILE--
- <?php
- echo "*** Testing basic functions of pathinfo() ***\n";
- $paths = array (
- '',
- ' ',
- 'c:',
- 'c:\\',
- 'c:/',
- 'afile',
- 'c:\test\adir',
- 'c:\test\adir\\',
- '/usr/include/arpa',
- '/usr/include/arpa/',
- 'usr/include/arpa',
- 'usr/include/arpa/',
- 'c:\test\afile',
- 'c:\\test\\afile',
- 'c://test//afile',
- 'c:\test\afile\\',
- 'c:\test\prog.exe',
- 'c:\\test\\prog.exe',
- 'c:/test/prog.exe',
- '/usr/include/arpa/inet.h',
- '//usr/include//arpa/inet.h',
- '\\',
- '\\\\',
- '/',
- '//',
- '///',
- '/usr/include/arpa/inet.h',
- 'c:\windows/system32\drivers/etc\hosts',
- '/usr\include/arpa\inet.h',
- ' c:\test\adir\afile.txt',
- 'c:\test\adir\afile.txt ',
- ' c:\test\adir\afile.txt ',
- ' /usr/include/arpa/inet.h',
- '/usr/include/arpa/inet.h ',
- ' /usr/include/arpa/inet.h ',
- ' c:',
- ' c:\test\adir\afile.txt',
- '/usr',
- '/usr/'
- );
- $counter = 1;
- /* loop through $paths to test each $path in the above array */
- foreach($paths as $path) {
- echo "-- Iteration $counter --\n";
- var_dump( pathinfo($path, PATHINFO_DIRNAME) );
- var_dump( pathinfo($path, PATHINFO_BASENAME) );
- var_dump( pathinfo($path, PATHINFO_EXTENSION) );
- var_dump( pathinfo($path, PATHINFO_FILENAME) );
- var_dump( pathinfo($path) );
- $counter++;
- }
- echo "Done\n";
- ?>
- --EXPECT--
- *** Testing basic functions of pathinfo() ***
- -- Iteration 1 --
- string(0) ""
- string(0) ""
- string(0) ""
- string(0) ""
- array(2) {
- ["basename"]=>
- string(0) ""
- ["filename"]=>
- string(0) ""
- }
- -- Iteration 2 --
- string(1) "."
- string(1) " "
- string(0) ""
- string(1) " "
- array(3) {
- ["dirname"]=>
- string(1) "."
- ["basename"]=>
- string(1) " "
- ["filename"]=>
- string(1) " "
- }
- -- Iteration 3 --
- string(2) "c:"
- string(1) "c"
- string(0) ""
- string(1) "c"
- array(3) {
- ["dirname"]=>
- string(2) "c:"
- ["basename"]=>
- string(1) "c"
- ["filename"]=>
- string(1) "c"
- }
- -- Iteration 4 --
- string(3) "c:\"
- string(1) "c"
- string(0) ""
- string(1) "c"
- array(3) {
- ["dirname"]=>
- string(3) "c:\"
- ["basename"]=>
- string(1) "c"
- ["filename"]=>
- string(1) "c"
- }
- -- Iteration 5 --
- string(3) "c:\"
- string(1) "c"
- string(0) ""
- string(1) "c"
- array(3) {
- ["dirname"]=>
- string(3) "c:\"
- ["basename"]=>
- string(1) "c"
- ["filename"]=>
- string(1) "c"
- }
- -- Iteration 6 --
- string(1) "."
- string(5) "afile"
- string(0) ""
- string(5) "afile"
- array(3) {
- ["dirname"]=>
- string(1) "."
- ["basename"]=>
- string(5) "afile"
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 7 --
- string(7) "c:\test"
- string(4) "adir"
- string(0) ""
- string(4) "adir"
- array(3) {
- ["dirname"]=>
- string(7) "c:\test"
- ["basename"]=>
- string(4) "adir"
- ["filename"]=>
- string(4) "adir"
- }
- -- Iteration 8 --
- string(7) "c:\test"
- string(4) "adir"
- string(0) ""
- string(4) "adir"
- array(3) {
- ["dirname"]=>
- string(7) "c:\test"
- ["basename"]=>
- string(4) "adir"
- ["filename"]=>
- string(4) "adir"
- }
- -- Iteration 9 --
- string(12) "/usr/include"
- string(4) "arpa"
- string(0) ""
- string(4) "arpa"
- array(3) {
- ["dirname"]=>
- string(12) "/usr/include"
- ["basename"]=>
- string(4) "arpa"
- ["filename"]=>
- string(4) "arpa"
- }
- -- Iteration 10 --
- string(12) "/usr/include"
- string(4) "arpa"
- string(0) ""
- string(4) "arpa"
- array(3) {
- ["dirname"]=>
- string(12) "/usr/include"
- ["basename"]=>
- string(4) "arpa"
- ["filename"]=>
- string(4) "arpa"
- }
- -- Iteration 11 --
- string(11) "usr/include"
- string(4) "arpa"
- string(0) ""
- string(4) "arpa"
- array(3) {
- ["dirname"]=>
- string(11) "usr/include"
- ["basename"]=>
- string(4) "arpa"
- ["filename"]=>
- string(4) "arpa"
- }
- -- Iteration 12 --
- string(11) "usr/include"
- string(4) "arpa"
- string(0) ""
- string(4) "arpa"
- array(3) {
- ["dirname"]=>
- string(11) "usr/include"
- ["basename"]=>
- string(4) "arpa"
- ["filename"]=>
- string(4) "arpa"
- }
- -- Iteration 13 --
- string(7) "c:\test"
- string(5) "afile"
- string(0) ""
- string(5) "afile"
- array(3) {
- ["dirname"]=>
- string(7) "c:\test"
- ["basename"]=>
- string(5) "afile"
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 14 --
- string(7) "c:\test"
- string(5) "afile"
- string(0) ""
- string(5) "afile"
- array(3) {
- ["dirname"]=>
- string(7) "c:\test"
- ["basename"]=>
- string(5) "afile"
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 15 --
- string(8) "c://test"
- string(5) "afile"
- string(0) ""
- string(5) "afile"
- array(3) {
- ["dirname"]=>
- string(8) "c://test"
- ["basename"]=>
- string(5) "afile"
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 16 --
- string(7) "c:\test"
- string(5) "afile"
- string(0) ""
- string(5) "afile"
- array(3) {
- ["dirname"]=>
- string(7) "c:\test"
- ["basename"]=>
- string(5) "afile"
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 17 --
- string(7) "c:\test"
- string(8) "prog.exe"
- string(3) "exe"
- string(4) "prog"
- array(4) {
- ["dirname"]=>
- string(7) "c:\test"
- ["basename"]=>
- string(8) "prog.exe"
- ["extension"]=>
- string(3) "exe"
- ["filename"]=>
- string(4) "prog"
- }
- -- Iteration 18 --
- string(7) "c:\test"
- string(8) "prog.exe"
- string(3) "exe"
- string(4) "prog"
- array(4) {
- ["dirname"]=>
- string(7) "c:\test"
- ["basename"]=>
- string(8) "prog.exe"
- ["extension"]=>
- string(3) "exe"
- ["filename"]=>
- string(4) "prog"
- }
- -- Iteration 19 --
- string(7) "c:/test"
- string(8) "prog.exe"
- string(3) "exe"
- string(4) "prog"
- array(4) {
- ["dirname"]=>
- string(7) "c:/test"
- ["basename"]=>
- string(8) "prog.exe"
- ["extension"]=>
- string(3) "exe"
- ["filename"]=>
- string(4) "prog"
- }
- -- Iteration 20 --
- string(17) "/usr/include/arpa"
- string(6) "inet.h"
- string(1) "h"
- string(4) "inet"
- array(4) {
- ["dirname"]=>
- string(17) "/usr/include/arpa"
- ["basename"]=>
- string(6) "inet.h"
- ["extension"]=>
- string(1) "h"
- ["filename"]=>
- string(4) "inet"
- }
- -- Iteration 21 --
- string(19) "//usr/include//arpa"
- string(6) "inet.h"
- string(1) "h"
- string(4) "inet"
- array(4) {
- ["dirname"]=>
- string(19) "//usr/include//arpa"
- ["basename"]=>
- string(6) "inet.h"
- ["extension"]=>
- string(1) "h"
- ["filename"]=>
- string(4) "inet"
- }
- -- Iteration 22 --
- string(1) "\"
- string(0) ""
- string(0) ""
- string(0) ""
- array(3) {
- ["dirname"]=>
- string(1) "\"
- ["basename"]=>
- string(0) ""
- ["filename"]=>
- string(0) ""
- }
- -- Iteration 23 --
- string(1) "\"
- string(0) ""
- string(0) ""
- string(0) ""
- array(3) {
- ["dirname"]=>
- string(1) "\"
- ["basename"]=>
- string(0) ""
- ["filename"]=>
- string(0) ""
- }
- -- Iteration 24 --
- string(1) "\"
- string(0) ""
- string(0) ""
- string(0) ""
- array(3) {
- ["dirname"]=>
- string(1) "\"
- ["basename"]=>
- string(0) ""
- ["filename"]=>
- string(0) ""
- }
- -- Iteration 25 --
- string(1) "\"
- string(0) ""
- string(0) ""
- string(0) ""
- array(3) {
- ["dirname"]=>
- string(1) "\"
- ["basename"]=>
- string(0) ""
- ["filename"]=>
- string(0) ""
- }
- -- Iteration 26 --
- string(1) "\"
- string(0) ""
- string(0) ""
- string(0) ""
- array(3) {
- ["dirname"]=>
- string(1) "\"
- ["basename"]=>
- string(0) ""
- ["filename"]=>
- string(0) ""
- }
- -- Iteration 27 --
- string(17) "/usr/include/arpa"
- string(6) "inet.h"
- string(1) "h"
- string(4) "inet"
- array(4) {
- ["dirname"]=>
- string(17) "/usr/include/arpa"
- ["basename"]=>
- string(6) "inet.h"
- ["extension"]=>
- string(1) "h"
- ["filename"]=>
- string(4) "inet"
- }
- -- Iteration 28 --
- string(31) "c:\windows/system32\drivers/etc"
- string(5) "hosts"
- string(0) ""
- string(5) "hosts"
- array(3) {
- ["dirname"]=>
- string(31) "c:\windows/system32\drivers/etc"
- ["basename"]=>
- string(5) "hosts"
- ["filename"]=>
- string(5) "hosts"
- }
- -- Iteration 29 --
- string(17) "/usr\include/arpa"
- string(6) "inet.h"
- string(1) "h"
- string(4) "inet"
- array(4) {
- ["dirname"]=>
- string(17) "/usr\include/arpa"
- ["basename"]=>
- string(6) "inet.h"
- ["extension"]=>
- string(1) "h"
- ["filename"]=>
- string(4) "inet"
- }
- -- Iteration 30 --
- string(15) " c:\test\adir"
- string(9) "afile.txt"
- string(3) "txt"
- string(5) "afile"
- array(4) {
- ["dirname"]=>
- string(15) " c:\test\adir"
- ["basename"]=>
- string(9) "afile.txt"
- ["extension"]=>
- string(3) "txt"
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 31 --
- string(12) "c:\test\adir"
- string(12) "afile.txt "
- string(6) "txt "
- string(5) "afile"
- array(4) {
- ["dirname"]=>
- string(12) "c:\test\adir"
- ["basename"]=>
- string(12) "afile.txt "
- ["extension"]=>
- string(6) "txt "
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 32 --
- string(15) " c:\test\adir"
- string(12) "afile.txt "
- string(6) "txt "
- string(5) "afile"
- array(4) {
- ["dirname"]=>
- string(15) " c:\test\adir"
- ["basename"]=>
- string(12) "afile.txt "
- ["extension"]=>
- string(6) "txt "
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 33 --
- string(20) " /usr/include/arpa"
- string(6) "inet.h"
- string(1) "h"
- string(4) "inet"
- array(4) {
- ["dirname"]=>
- string(20) " /usr/include/arpa"
- ["basename"]=>
- string(6) "inet.h"
- ["extension"]=>
- string(1) "h"
- ["filename"]=>
- string(4) "inet"
- }
- -- Iteration 34 --
- string(17) "/usr/include/arpa"
- string(9) "inet.h "
- string(4) "h "
- string(4) "inet"
- array(4) {
- ["dirname"]=>
- string(17) "/usr/include/arpa"
- ["basename"]=>
- string(9) "inet.h "
- ["extension"]=>
- string(4) "h "
- ["filename"]=>
- string(4) "inet"
- }
- -- Iteration 35 --
- string(20) " /usr/include/arpa"
- string(9) "inet.h "
- string(4) "h "
- string(4) "inet"
- array(4) {
- ["dirname"]=>
- string(20) " /usr/include/arpa"
- ["basename"]=>
- string(9) "inet.h "
- ["extension"]=>
- string(4) "h "
- ["filename"]=>
- string(4) "inet"
- }
- -- Iteration 36 --
- string(1) "."
- string(3) " c:"
- string(0) ""
- string(3) " c:"
- array(3) {
- ["dirname"]=>
- string(1) "."
- ["basename"]=>
- string(3) " c:"
- ["filename"]=>
- string(3) " c:"
- }
- -- Iteration 37 --
- string(14) " c:\test\adir"
- string(9) "afile.txt"
- string(3) "txt"
- string(5) "afile"
- array(4) {
- ["dirname"]=>
- string(14) " c:\test\adir"
- ["basename"]=>
- string(9) "afile.txt"
- ["extension"]=>
- string(3) "txt"
- ["filename"]=>
- string(5) "afile"
- }
- -- Iteration 38 --
- string(1) "\"
- string(3) "usr"
- string(0) ""
- string(3) "usr"
- array(3) {
- ["dirname"]=>
- string(1) "\"
- ["basename"]=>
- string(3) "usr"
- ["filename"]=>
- string(3) "usr"
- }
- -- Iteration 39 --
- string(1) "\"
- string(3) "usr"
- string(0) ""
- string(3) "usr"
- array(3) {
- ["dirname"]=>
- string(1) "\"
- ["basename"]=>
- string(3) "usr"
- ["filename"]=>
- string(3) "usr"
- }
- Done
|