1--TEST--
2Test readdir() function : usage variations - empty directories
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 * Pass readdir() a directory handle pointing to an empty directory to test behaviour
12 */
13
14echo "*** Testing readdir() : usage variations ***\n";
15
16$path = dirname(__FILE__) . '/readdir_variation2';
17mkdir($path);
18$dir_handle = opendir($path);
19
20echo "\n-- Pass an empty directory to readdir() --\n";
21function mysort($a,$b) {
22	return strlen($a) > strlen($b) ? 1 : -1;
23}
24$entries = array();
25while(FALSE !== ($file = readdir($dir_handle))){
26	$entries[] = $file;
27}
28
29closedir($dir_handle);
30
31usort($entries, "mysort");
32foreach($entries as $entry) {
33	var_dump($entry);
34}
35?>
36===DONE===
37--CLEAN--
38<?php
39$path = dirname(__FILE__) . '/readdir_variation2';
40rmdir($path);
41?>
42--EXPECTF--
43*** Testing readdir() : usage variations ***
44
45-- Pass an empty directory to readdir() --
46string(1) "."
47string(2) ".."
48===DONE===
49