1--TEST--
2Test readdir() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : string readdir([resource $dir_handle])
6 * Description: Read directory entry from dir_handle
7 * Source code: ext/standard/dir.C
8 */
9
10/*
11 * Test basic functionality of readdir()
12 */
13
14echo "*** Testing readdir() : basic functionality ***\n";
15
16// include the file.inc for Function: function create_files()
17chdir(dirname(__FILE__));
18include(dirname(__FILE__)."/../file/file.inc");
19
20$path = dirname(__FILE__) . '/readdir_basic';
21mkdir($path);
22create_files($path, 3);
23
24echo "\n-- Call readdir() with \$path argument --\n";
25var_dump($dh = opendir($path));
26$a = array();
27while( FALSE !== ($file = readdir($dh)) ) {
28	$a[] = $file;
29}
30sort($a);
31foreach($a as $file) {
32	var_dump($file);
33}
34
35echo "\n-- Call readdir() without \$path argument --\n";
36var_dump($dh = opendir($path));
37$a = array();
38while( FALSE !== ( $file = readdir() ) ) {
39	$a[] = $file;
40}
41sort($a);
42foreach($a as $file) {
43	var_dump($file);
44}
45
46delete_files($path, 3);
47closedir($dh);
48?>
49===DONE===
50--CLEAN--
51<?php
52$path = dirname(__FILE__) . '/readdir_basic';
53rmdir($path);
54?>
55--EXPECTF--
56*** Testing readdir() : basic functionality ***
57
58-- Call readdir() with $path argument --
59resource(%d) of type (stream)
60string(1) "."
61string(2) ".."
62string(9) "file1.tmp"
63string(9) "file2.tmp"
64string(9) "file3.tmp"
65
66-- Call readdir() without $path argument --
67resource(%d) of type (stream)
68string(1) "."
69string(2) ".."
70string(9) "file1.tmp"
71string(9) "file2.tmp"
72string(9) "file3.tmp"
73===DONE===
74