glob_variation2.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test glob() function with relative path
  3. --FILE--
  4. <?php
  5. /* Prototype: array glob ( string $pattern [, int $flags] );
  6. Description: Find pathnames matching a pattern
  7. */
  8. $file_path = dirname(__FILE__);
  9. // temp dirname used here
  10. $dir_name = 'glob_test';
  11. // create temp directory
  12. mkdir("$file_path/$dir_name");
  13. // create temp file
  14. $fp = fopen("$file_path/$dir_name/file.text", "w");
  15. fclose($fp);
  16. echo "Testing glob() with relative paths:\n";
  17. chdir("$file_path/$dir_name");
  18. var_dump( glob("./*") );
  19. var_dump( glob("../$dir_name/*"));
  20. chdir("$file_path");
  21. var_dump( glob("$dir_name/*"));
  22. var_dump( glob("$dir_name"));
  23. echo "Done\n";
  24. ?>
  25. --CLEAN--
  26. <?php
  27. $file_path = dirname(__FILE__);
  28. unlink("$file_path/glob_test/file.text");
  29. rmdir("$file_path/glob_test/");
  30. ?>
  31. --EXPECT--
  32. Testing glob() with relative paths:
  33. array(1) {
  34. [0]=>
  35. string(11) "./file.text"
  36. }
  37. array(1) {
  38. [0]=>
  39. string(22) "../glob_test/file.text"
  40. }
  41. array(1) {
  42. [0]=>
  43. string(19) "glob_test/file.text"
  44. }
  45. array(1) {
  46. [0]=>
  47. string(9) "glob_test"
  48. }
  49. Done