1--TEST--
2Test readdir() function : usage variations - operate on previously opened directory
3--FILE--
4<?php
5/*
6 * Open two directory handles on the same directory and pass both
7 * to readdir() to test behaviour
8 */
9
10echo "*** Testing readdir() : usage variations ***\n";
11
12// include the file.inc for Function: function create_files()
13include( __DIR__."/../file/file.inc");
14
15// create the temporary directory
16$dir_path = __DIR__ . "/readdir_variation6";
17mkdir($dir_path);
18
19// create files within the temporary directory
20create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "readdir_variation6");
21
22// open the directory
23$dir_handle1 = opendir($dir_path);
24
25// open the same directory again without closing it
26opendir($dir_path);
27
28echo "\n-- Reading Directory Contents with Previous Handle --\n";
29$a = array();
30while (FALSE !== ($file = readdir($dir_handle1))) {
31    $a[] = $file;
32}
33sort($a);
34foreach ($a as $file) {
35    var_dump($file);
36}
37
38echo "\n-- Reading Directory Contents with Current Handle (no arguments supplied) --\n";
39$a = array();
40while (FALSE !== ($file = readdir())) {
41    $a[] = $file;
42}
43sort($a);
44foreach ($a as $file) {
45    var_dump($file);
46}
47
48// delete temporary files
49delete_files($dir_path, 3, "readdir_variation6");
50closedir($dir_handle1);
51closedir();
52?>
53--CLEAN--
54<?php
55$dir_path = __DIR__ . "/readdir_variation6";
56rmdir($dir_path);
57?>
58--EXPECT--
59*** Testing readdir() : usage variations ***
60
61-- Reading Directory Contents with Previous Handle --
62string(1) "."
63string(2) ".."
64string(23) "readdir_variation61.tmp"
65string(23) "readdir_variation62.tmp"
66string(23) "readdir_variation63.tmp"
67
68-- Reading Directory Contents with Current Handle (no arguments supplied) --
69string(1) "."
70string(2) ".."
71string(23) "readdir_variation61.tmp"
72string(23) "readdir_variation62.tmp"
73string(23) "readdir_variation63.tmp"
74