1--TEST-- 2Test opendir() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : mixed opendir(string $path[, resource $context]) 6 * Description: Open a directory and return a dir_handle 7 * Source code: ext/standard/dir.c 8 */ 9 10/* 11 * Test basic functionality of opendir() with absolute and relative paths as $path argument 12 */ 13 14echo "*** Testing opendir() : basic functionality ***\n"; 15 16$base_dir_path = __DIR__ . '/opendir_basic'; 17@mkdir($base_dir_path); 18 19$level_one_dir_name = "level_one"; 20$level_one_dir_path = "$base_dir_path/$level_one_dir_name"; 21 22$level_two_dir_name = "level_two"; 23$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name"; 24 25// create temporary directories - will remove in CLEAN section 26mkdir($level_one_dir_path); 27mkdir($level_two_dir_path); 28 29echo "\n-- Testing opendir() with absolute path: --\n"; 30var_dump($dh1 = opendir($level_one_dir_path)); 31 32 33echo "\n-- Testing opendir() with relative paths: --\n"; 34var_dump(chdir($level_one_dir_path)); 35var_dump($dh2 = opendir($level_two_dir_name)); 36 37echo "\n-- Close directory handles: --\n"; 38closedir($dh1); 39var_dump($dh1); 40closedir($dh2); 41var_dump($dh2); 42?> 43===DONE=== 44--CLEAN-- 45<?php 46$base_dir_path = __DIR__ . '/opendir_basic'; 47rmdir("$base_dir_path/level_one/level_two"); 48rmdir("$base_dir_path/level_one"); 49rmdir($base_dir_path); 50?> 51--EXPECTF-- 52*** Testing opendir() : basic functionality *** 53 54-- Testing opendir() with absolute path: -- 55resource(%d) of type (stream) 56 57-- Testing opendir() with relative paths: -- 58bool(true) 59resource(%d) of type (stream) 60 61-- Close directory handles: -- 62resource(%d) of type (Unknown) 63resource(%d) of type (Unknown) 64===DONE=== 65