1--TEST-- 2Test readdir() function : usage variations - sub-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 a directory handle pointing to a directory that has a sub-directory 18 * to test behaviour of readdir() 19 */ 20 21echo "*** Testing readdir() : usage variations ***\n"; 22 23// include the file.inc for Function: function create_files() 24chdir(dirname(__FILE__)); 25include(dirname(__FILE__)."/../file/file.inc"); 26 27$path_top = dirname(__FILE__) . '/readdir_variation3'; 28$path_sub = $path_top . '/私はガラスを食べられますsub_folder'; 29mkdir($path_top); 30mkdir($path_sub); 31 32create_files($path_top, 2); 33create_files($path_sub, 2); 34 35$dir_handle = opendir($path_top); 36while(FALSE !== ($file = readdir($dir_handle))) { 37 38 // different OS order files differently so will 39 // store file names into an array so can use sorted in expected output 40 $contents[] = $file; 41} 42 43// more important to check that all contents are present than order they are returned in 44sort($contents); 45var_dump($contents); 46 47delete_files($path_top, 2); 48delete_files($path_sub, 2); 49 50closedir($dir_handle); 51?> 52===DONE=== 53--CLEAN-- 54<?php 55$path_top = dirname(__FILE__) . '/readdir_variation3'; 56$path_sub = $path_top . '/私はガラスを食べられますsub_folder'; 57rmdir($path_sub); 58rmdir($path_top); 59?> 60--EXPECTF-- 61*** Testing readdir() : usage variations *** 62array(5) { 63 [0]=> 64 string(1) "." 65 [1]=> 66 string(2) ".." 67 [2]=> 68 string(9) "file1.tmp" 69 [3]=> 70 string(9) "file2.tmp" 71 [4]=> 72 string(46) "私はガラスを食べられますsub_folder" 73} 74===DONE=== 75