PHP fgets() လုပ်ဆောင်ချက်
❮ PHP ဖိုင်စနစ် အကိုးအကားဥပမာ
အဖွင့်ဖိုင်မှ စာကြောင်းတစ်ကြောင်းကို ဖတ်ပါ-
<?php
$file = fopen("test.txt","r");
echo fgets($file);
fclose($file);
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
fgets() လုပ်ဆောင်ချက်သည် အဖွင့်ဖိုင်တစ်ခုမှ လိုင်းတစ်ခုကို ပြန်ပေးသည်။
အထားအသို
fgets(file, length)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
file | Required. Specifies the open file to return a line from |
length | Optional. Specifies the number of bytes to read. Reading stops when length-1 bytes have been reached, or when a new line occurs, or on EOF. If no length is specified, it reads until end of the line |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အောင်မြင်မှုပေါ်ရှိ ဖိုင်မှဖတ်သော စာကြောင်းတစ်ကြောင်း၊ EOF တွင် မှားနေသည် သို့မဟုတ် အမှားအယွင်းရှိသည်။ |
---|---|
PHP ဗားရှင်း- | 4.0+ |
Binary Safe- | ဟုတ်ပါတယ်၊ PHP 4.3 မှာ |
နောက်ထပ် ဥပမာများ
ဥပမာ
ဖိုင်ကိုဖွင့်ဖတ်ပါ၊ လိုင်းတစ်ခုပြီးတစ်ခုဖတ်ပါ။
<?php
$file = fopen("test.txt","r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
❮ PHP ဖိုင်စနစ် အကိုးအကား