dir_variation4.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. Test dir() function : usage variations - operate on previously opened directory
  3. --FILE--
  4. <?php
  5. /*
  6. * Testing the behavior of dir() function by trying to open a
  7. * directory which is already open.
  8. */
  9. echo "*** Testing dir() : operate on previously opened directory ***\n";
  10. // include the file.inc for Function: function create_files()
  11. include( __DIR__."/../file/file.inc");
  12. // create the temporary directory
  13. $file_path = __DIR__;
  14. $dir_path = $file_path."/dir_variation4";
  15. @mkdir($dir_path);
  16. // create files within the temporary directory
  17. create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "dir_variation4");
  18. // open the directory
  19. $d = dir($dir_path);
  20. var_dump( $d );
  21. // open the same directory again without closing it
  22. $e = dir($dir_path);
  23. var_dump( $e );
  24. echo "-- reading directory contents with previous handle --\n";
  25. var_dump( $d->read() ); // with previous handle
  26. echo "-- reading directory contents with current handle --\n";
  27. var_dump( $e->read() ); // with current handle
  28. // delete temporary files
  29. delete_files($dir_path, 3, "dir_variation4");
  30. echo "Done";
  31. ?>
  32. --CLEAN--
  33. <?php
  34. $file_path = __DIR__;
  35. $dir_path = $file_path."/dir_variation4";
  36. rmdir($dir_path);
  37. ?>
  38. --EXPECTF--
  39. *** Testing dir() : operate on previously opened directory ***
  40. object(Directory)#%d (2) {
  41. ["path"]=>
  42. string(%d) "%s/dir_variation4"
  43. ["handle"]=>
  44. resource(%d) of type (stream)
  45. }
  46. object(Directory)#%d (2) {
  47. ["path"]=>
  48. string(%d) "%s/dir_variation4"
  49. ["handle"]=>
  50. resource(%d) of type (stream)
  51. }
  52. -- reading directory contents with previous handle --
  53. string(%d) "%s"
  54. -- reading directory contents with current handle --
  55. string(%d) "%s"
  56. Done