2 /* Prototype : string readdir([resource $dir_handle])
3 * Description: Read directory entry from dir_handle
4 * Source code: ext/standard/dir.c
8 * Pass a directory handle pointing to a directory that contains
9 * files with different file names to test how readdir() reads them
11 <<__EntryPoint
>> function main(): void
{
12 echo "*** Testing readdir() : usage variations ***\n";
14 $dir_path = dirname(__FILE__
) . "/readdir_variation4/";
48 foreach($inputs as $key => $input) {
49 echo "\n-- Iteration $iterator --\n";
50 $handle = "fp{$iterator}";
51 var_dump( $handle = fopen(@"$dir_path$input.tmp", 'w') );
52 try { var_dump( fwrite($handle, $key)); } catch (Exception
$e) { var_dump($e->getMessage()); }
57 echo "\n-- Call to readdir() --\n";
58 $dir_handle = opendir($dir_path);
60 while(FALSE !== ($file = readdir($dir_handle))){
62 // different OS order files differently so will
63 // store file names into an array so can use sorted in expected output
66 // remove files while going through directory
67 @unlink
($dir_path . $file);
70 // more important to check that all contents are present than order they are returned in
71 sort(inout
$contents);
74 closedir($dir_handle);
77 $dir_path = dirname(__FILE__
) . "/readdir_variation4/";