首頁  >  文章  >  後端開發  >  PHP中opendir的用法

PHP中opendir的用法

angryTom
angryTom原創
2019-08-24 10:04:402524瀏覽

PHP中opendir的用法

PHP opendir() 函數

##」實例




# #
<?php
$dir = "/images/";

// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
echo "filename:" . $file . "<br>";
}
closedir($dh);
}
}
?>
結果  opendir() 函式開啟目錄句柄。
filename: cat.gif
filename: dog.gif
filename: horse.gif
定義與用法
語法
opendir(path,context);
#參數

描述

path必要。規定要開啟的目錄路徑。 可選。規定目錄句柄的環境。 context 是可修改目錄流的行為的一套選項。
context
技術細節
####### 傳回值:#######成功則傳回目錄句柄資源。失敗則傳回 FALSE。如果路徑不是合法目錄,或由於許可證限製或檔案系統錯誤導致的目錄不能打開,則拋出 E_WARNING 層級的錯誤。您可以透過在函數名稱前面加上 '@' 來隱藏 opendir() 的錯誤輸出。 ############PHP 版本:######4.0 #############PHP 更新日誌:######PHP 5.0:path 參數支持###ftp://### URL 封裝協定。 ############

以上是PHP中opendir的用法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:php註釋的作用下一篇:php註釋的作用