opendir()函數(shù)的作用是:打開目錄句柄,如果該函數(shù)成功運行,將返回一組目錄流(一組目錄字符串),如果失敗將返回錯誤[error],你可以在函數(shù)的最前面加上“@”來隱藏錯誤.
syntax語法:opendir(directory,context) parameter
參數(shù):description
描述:directory required. specifies the directory to stream
必要參數(shù),指定目錄對象,可選參數(shù),指定需要處理的目錄對象的context,這個context包括了一組選項,它可以對文本流的顯示方式進(jìn)行改變,實例代碼如下:
- <?php
- $dir = "./";
- // open a known directory, and proceed to read its contents
- if (is_dir($dir))
- {
- if ($dh = opendir($dir)) {
- while (($file = readdir($dh)) !== false) {
- echo "filename: $file : filetype: " . filetype($dir . $file) . "n"."<br />";
- } //開源代碼Vevb.com
- closedir($dh);
- }
- }
- ?>
新聞熱點
疑難解答