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 = dirname(__FILE__); 17 18$level_one_dir_name = "level_one"; 19$level_one_dir_path = "$base_dir_path/$level_one_dir_name"; 20 21$level_two_dir_name = "level_two"; 22$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name"; 23 24// create temporary directories - will remove in CLEAN section 25mkdir($level_one_dir_path); 26mkdir($level_two_dir_path); 27 28echo "\n-- Testing opendir() with absolute path: --\n"; 29var_dump($dh1 = opendir($level_one_dir_path)); 30 31 32echo "\n-- Testing opendir() with relative paths: --\n"; 33var_dump(chdir($level_one_dir_path)); 34var_dump($dh2 = opendir($level_two_dir_name)); 35 36echo "\n-- Close directory handles: --\n"; 37closedir($dh1); 38var_dump($dh1); 39closedir($dh2); 40var_dump($dh2); 41?> 42===DONE=== 43--CLEAN-- 44<?php 45$file_path = dirname(__FILE__); 46rmdir("$file_path/level_one/level_two"); 47rmdir("$file_path/level_one"); 48?> 49--EXPECTF-- 50*** Testing opendir() : basic functionality *** 51 52-- Testing opendir() with absolute path: -- 53resource(%d) of type (stream) 54 55-- Testing opendir() with relative paths: -- 56bool(true) 57resource(%d) of type (stream) 58 59-- Close directory handles: -- 60resource(%d) of type (Unknown) 61resource(%d) of type (Unknown) 62===DONE=== 63