1--TEST-- 2Test dir() function : usage variations - operate on previously opened directory 3--FILE-- 4<?php 5/* 6 * Testing the behavior of dir() function by trying to open a 7 * directory which is already open. 8 */ 9 10echo "*** Testing dir() : operate on previously opened directory ***\n"; 11 12// include the file.inc for Function: function create_files() 13include( __DIR__."/../file/file.inc"); 14 15// create the temporary directory 16$file_path = __DIR__; 17$dir_path = $file_path."/dir_variation4"; 18@mkdir($dir_path); 19 20// create files within the temporary directory 21create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "dir_variation4"); 22 23// open the directory 24$d = dir($dir_path); 25var_dump( $d ); 26 27// open the same directory again without closing it 28$e = dir($dir_path); 29var_dump( $e ); 30 31echo "-- reading directory contents with previous handle --\n"; 32var_dump( $d->read() ); // with previous handle 33 34echo "-- reading directory contents with current handle --\n"; 35var_dump( $e->read() ); // with current handle 36 37// delete temporary files 38delete_files($dir_path, 3, "dir_variation4"); 39echo "Done"; 40?> 41--CLEAN-- 42<?php 43$file_path = __DIR__; 44$dir_path = $file_path."/dir_variation4"; 45 46rmdir($dir_path); 47?> 48--EXPECTF-- 49*** Testing dir() : operate on previously opened directory *** 50object(Directory)#%d (2) { 51 ["path"]=> 52 string(%d) "%s/dir_variation4" 53 ["handle"]=> 54 resource(%d) of type (stream) 55} 56object(Directory)#%d (2) { 57 ["path"]=> 58 string(%d) "%s/dir_variation4" 59 ["handle"]=> 60 resource(%d) of type (stream) 61} 62-- reading directory contents with previous handle -- 63string(%d) "%s" 64-- reading directory contents with current handle -- 65string(%d) "%s" 66Done 67