1--TEST-- 2Test readdir() function : usage variations - operate on previously opened directory 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 * Open two directory handles on the same directory and pass both 12 * to readdir() to test behaviour 13 */ 14 15echo "*** Testing readdir() : usage variations ***\n"; 16 17// include the file.inc for Function: function create_files() 18include( dirname(__FILE__)."/../file/file.inc"); 19 20// create the temporary directory 21$dir_path = dirname(__FILE__) . "/readdir_variation6"; 22mkdir($dir_path); 23 24// create files within the temporary directory 25create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "readdir_variation6"); 26 27// open the directory 28$dir_handle1 = opendir($dir_path); 29 30// open the same directory again without closing it 31opendir($dir_path); 32 33echo "\n-- Reading Directory Contents with Previous Handle --\n"; 34$a = array(); 35while (FALSE !== ($file = readdir($dir_handle1))) { 36 $a[] = $file; 37} 38sort($a); 39foreach ($a as $file) { 40 var_dump($file); 41} 42 43echo "\n-- Reading Directory Contents with Current Handle (no arguments supplied) --\n"; 44$a = array(); 45while (FALSE !== ($file = readdir())) { 46 $a[] = $file; 47} 48sort($a); 49foreach ($a as $file) { 50 var_dump($file); 51} 52 53// delete temporary files 54delete_files($dir_path, 3, "readdir_variation6"); 55closedir($dir_handle1); 56closedir(); 57?> 58===DONE=== 59--CLEAN-- 60<?php 61$dir_path = dirname(__FILE__) . "/readdir_variation6"; 62rmdir($dir_path); 63?> 64--EXPECTF-- 65*** Testing readdir() : usage variations *** 66 67-- Reading Directory Contents with Previous Handle -- 68string(1) "." 69string(2) ".." 70string(23) "readdir_variation61.tmp" 71string(23) "readdir_variation62.tmp" 72string(23) "readdir_variation63.tmp" 73 74-- Reading Directory Contents with Current Handle (no arguments supplied) -- 75string(1) "." 76string(2) ".." 77string(23) "readdir_variation61.tmp" 78string(23) "readdir_variation62.tmp" 79string(23) "readdir_variation63.tmp" 80===DONE=== 81