1--TEST--
2Test readdir() function : usage variations - empty directories
3--FILE--
4<?php
5/*
6 * Pass readdir() a directory handle pointing to an empty directory to test behaviour
7 */
8
9echo "*** Testing readdir() : usage variations ***\n";
10
11$path = __DIR__ . '/readdir_variation2';
12mkdir($path);
13$dir_handle = opendir($path);
14
15echo "\n-- Pass an empty directory to readdir() --\n";
16function mysort($a,$b) {
17    return strlen($a) > strlen($b) ? 1 : -1;
18}
19$entries = array();
20while(FALSE !== ($file = readdir($dir_handle))){
21    $entries[] = $file;
22}
23
24closedir($dir_handle);
25
26usort($entries, "mysort");
27foreach($entries as $entry) {
28    var_dump($entry);
29}
30?>
31--CLEAN--
32<?php
33$path = __DIR__ . '/readdir_variation2';
34rmdir($path);
35?>
36--EXPECT--
37*** Testing readdir() : usage variations ***
38
39-- Pass an empty directory to readdir() --
40string(1) "."
41string(2) ".."
42