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);
}
}
?>
ရလဒ်:
filename: cat.gif
filename: dog.gif
filename: horse.gif
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
opendir() လုပ်ဆောင်ချက်သည် လမ်းညွှန်လက်ကိုင်တစ်ခုကို ဖွင့်ပေးသည်။
အထားအသို
opendir(path, context)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
path | Required. Specifies the directory path to be opened |
context | Optional. Specifies the context of the directory handle. Context is a set of options that can modify the behavior of a stream |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အောင်မြင်မှုပေါ်ရှိ လမ်းညွှန်လက်ကိုင်အရင်းအမြစ်ကို ပြန်ပေးသည်။ ရှုံးနိမ့်မှုအပေါ် မှားသည်။ လမ်းကြောင်းသည် တရားဝင်လမ်းကြောင်းမဟုတ်ပါက သို့မဟုတ် ခွင့်ပြုချက်ကန့်သတ်ချက်များ သို့မဟုတ် ဖိုင်စနစ်ဆိုင်ရာ အမှားအယွင်းများကြောင့် လမ်းညွှန်ကိုဖွင့်၍မရပါက အဆင့် E_WARNING ၏ အမှားတစ်ခုကို လွှင့်ပစ်ပါ။ လုပ်ဆောင်ချက်အမည်၏ ရှေ့တွင် '@' ကို ထည့်ခြင်းဖြင့် opendir() ၏ အမှားအယွင်းအထွက်ကို ဖျောက်နိုင်သည်။ |
---|---|
PHP ဗားရှင်း- | 4.0+ |
PHP Changelog- | PHP 5.0- လမ်းကြောင်း ကန့်သတ်ချက်သည် ftp:// URL ထုပ်ပိုး ခြင်းကို ပံ့ပိုးပေးနေပြီဖြစ်သည်။ |
❮ PHP လမ်းညွှန်အကိုးအကား