1--TEST-- 2Test readdir() function : usage variations - empty directories 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die("skip Valid only on Windows"); 7} 8?> 9--FILE-- 10<?php 11/* Prototype : string readdir([resource $dir_handle]) 12 * Description: Read directory entry from dir_handle 13 * Source code: ext/standard/dir.c 14 */ 15 16/* 17 * Pass readdir() a directory handle pointing to an empty directory to test behaviour 18 */ 19 20echo "*** Testing readdir() : usage variations ***\n"; 21 22$path = dirname(__FILE__) . '/私はガラスを食べられますreaddir_variation2'; 23mkdir($path); 24$dir_handle = opendir($path); 25 26echo "\n-- Pass an empty directory to readdir() --\n"; 27function mysort($a,$b) { 28 return strlen($a) > strlen($b) ? 1 : -1; 29} 30$entries = array(); 31while(FALSE !== ($file = readdir($dir_handle))){ 32 $entries[] = $file; 33} 34 35closedir($dir_handle); 36 37usort($entries, "mysort"); 38foreach($entries as $entry) { 39 var_dump($entry); 40} 41?> 42===DONE=== 43--CLEAN-- 44<?php 45$path = dirname(__FILE__) . '/私はガラスを食べられますreaddir_variation2'; 46rmdir($path); 47?> 48--EXPECT-- 49*** Testing readdir() : usage variations *** 50 51-- Pass an empty directory to readdir() -- 52string(1) "." 53string(2) ".." 54===DONE=== 55