1--TEST-- 2Test dir() function : usage variations - operate on previously opened directory 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/* 12 * Prototype : object dir(string $directory[, resource $context]) 13 * Description: Directory class with properties, handle and class and methods read, rewind and close 14 * Source code: ext/standard/dir.c 15 */ 16 17/* 18 * Testing the behavior of dir() function by trying to open a 19 * directory which is already open. 20 */ 21 22echo "*** Testing dir() : operate on previously opened directory ***\n"; 23 24// include the file.inc for Function: function create_files() 25include( __DIR__."/../file/file.inc"); 26 27// create the temporary directory 28$file_path = __DIR__; 29$dir_path = $file_path."/私はガラスを食べられますdir_variation4"; 30@mkdir($dir_path); 31 32// create files within the temporary directory 33create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "私はガラスを食べられますdir_variation4"); 34 35// open the directory 36$d = dir($dir_path); 37var_dump( $d ); 38 39// open the same directory again without closing it 40$e = dir($dir_path); 41var_dump( $e ); 42 43echo "-- reading directory contents with previous handle --\n"; 44var_dump( $d->read() ); // with previous handle 45 46echo "-- reading directory contents with current handle --\n"; 47var_dump( $e->read() ); // with current handle 48 49// delete temporary files 50delete_files($dir_path, 3, "私はガラスを食べられますdir_variation4"); 51echo "Done"; 52?> 53--CLEAN-- 54<?php 55$file_path = __DIR__; 56$dir_path = $file_path."/私はガラスを食べられますdir_variation4"; 57 58rmdir($dir_path); 59?> 60--EXPECTF-- 61*** Testing dir() : operate on previously opened directory *** 62object(Directory)#%d (2) { 63 ["path"]=> 64 string(%d) "%s/私はガラスを食べられますdir_variation4" 65 ["handle"]=> 66 resource(%d) of type (stream) 67} 68object(Directory)#%d (2) { 69 ["path"]=> 70 string(%d) "%s/私はガラスを食べられますdir_variation4" 71 ["handle"]=> 72 resource(%d) of type (stream) 73} 74-- reading directory contents with previous handle -- 75string(%d) "%s" 76-- reading directory contents with current handle -- 77string(%d) "%s" 78Done 79