pathinfo_basic1-win32.phpt 11 KB

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