glob_basic.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. Test glob() function: basic functions
  3. --FILE--
  4. <?php
  5. echo "*** Testing glob() : basic functions ***\n";
  6. $file_path = __DIR__;
  7. // temp dirname used here
  8. $dirname = "$file_path/glob_basic";
  9. // temp dir created
  10. mkdir($dirname);
  11. // temp files created
  12. $fp = fopen("$dirname/wonder12345", "w");
  13. fclose($fp);
  14. $fp = fopen("$dirname/wonder.txt", "w");
  15. fclose($fp);
  16. $fp = fopen("$dirname/file.text", "w");
  17. fclose($fp);
  18. // glob() with default arguments
  19. sort_var_dump( glob($dirname."/*") );
  20. sort_var_dump( glob($dirname."/*.txt") );
  21. sort_var_dump( glob($dirname."/*.t?t") );
  22. sort_var_dump( glob($dirname."/*.t*t") );
  23. sort_var_dump( glob($dirname."/*.?") );
  24. sort_var_dump( glob($dirname."/*.*") );
  25. echo "Done\n";
  26. function sort_var_dump($results) {
  27. sort($results);
  28. var_dump($results);
  29. }
  30. ?>
  31. --CLEAN--
  32. <?php
  33. $file_path = __DIR__;
  34. unlink("$file_path/glob_basic/wonder12345");
  35. unlink("$file_path/glob_basic/wonder.txt");
  36. unlink("$file_path/glob_basic/file.text");
  37. rmdir("$file_path/glob_basic/");
  38. ?>
  39. --EXPECTF--
  40. *** Testing glob() : basic functions ***
  41. array(3) {
  42. [0]=>
  43. string(%d) "%s/glob_basic/file.text"
  44. [1]=>
  45. string(%d) "%s/glob_basic/wonder.txt"
  46. [2]=>
  47. string(%d) "%s/glob_basic/wonder12345"
  48. }
  49. array(1) {
  50. [0]=>
  51. string(%d) "%s/glob_basic/wonder.txt"
  52. }
  53. array(1) {
  54. [0]=>
  55. string(%d) "%s/glob_basic/wonder.txt"
  56. }
  57. array(2) {
  58. [0]=>
  59. string(%d) "%s/glob_basic/file.text"
  60. [1]=>
  61. string(%d) "%s/glob_basic/wonder.txt"
  62. }
  63. array(0) {
  64. }
  65. array(2) {
  66. [0]=>
  67. string(%d) "%s/glob_basic/file.text"
  68. [1]=>
  69. string(%d) "%s/glob_basic/wonder.txt"
  70. }
  71. Done