opendir()函數(shù)的作用是:打開目錄句柄,如果該函數(shù)成功運(yùn)行,將返回一組目錄流(一組目錄字符串),如果失敗將返回錯誤[error],你可以在函數(shù)的最前面加上“@”來隱藏錯誤.
syntax語法:opendir(directory,context) parameter
參數(shù):description
描述:directory required. specifies the directory to stream
必要參數(shù),指定目錄對象,可選參數(shù),指定需要處理的目錄對象的context,這個context包括了一組選項,它可以對文本流的顯示方式進(jìn)行改變,實(shí)例代碼如下:
轉(zhuǎn)載請注明來源:php 目錄遍歷opendir函數(shù)
- <?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 />";
- } //開源代碼phpfensi.com
- closedir($dh);
- }
- }
- ?>
哈爾濱品用軟件有限公司致力于為哈爾濱的中小企業(yè)制作大氣、美觀的優(yōu)秀網(wǎng)站,并且能夠搭建符合百度排名規(guī)范的網(wǎng)站基底,使您的網(wǎng)站無需額外費(fèi)用,即可穩(wěn)步提升排名至首頁。歡迎體驗最佳的哈爾濱網(wǎng)站建設(shè)。
