PHP fseek() လုပ်ဆောင်ချက်
❮ PHP ဖိုင်စနစ် အကိုးအကားဥပမာ
အဖွင့်ဖိုင်မှ ပထမစာကြောင်းကို ဖတ်ပါ၊ ထို့နောက် ဖိုင်ညွှန်ပြချက်ကို ဖိုင်၏အစသို့ ပြန်ရွှေ့ပါ။
<?php
$file = fopen("test.txt","r");
// Read first line
echo fgets($file);
// Move back to beginning of file
fseek($file,0);
fclose($file);
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
fseek() လုပ်ဆောင်ချက်သည် အဖွင့်ဖိုင်တွင် ရှာဖွေသည်။
ဤလုပ်ဆောင်ချက်သည် ဖိုင်ညွှန်ပြသူကို ၎င်း၏လက်ရှိအနေအထားမှ bytes အရေအတွက်အလိုက် သတ်မှတ်ထားသော ရှေ့သို့ သို့မဟုတ် နောက်သို့ အနေအထားအသစ်သို့ ရွှေ့သည်။
အကြံပြုချက်- ftell() ကို အသုံးပြု၍ လက်ရှိအနေအထားကို သင်ရှာဖွေနိုင်သည်။
အထားအသို
fseek(file, offset, whence)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
file | Required. Specifies the open file to seek in |
offset | Required. Specifies the new position (measured in bytes from the beginning of the file) |
whence | Optional. Possible values:
|
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ဘ၀တွင် အောင်မြင်မှု မဟုတ်ရင်-၁ |
---|---|
PHP ဗားရှင်း- | 4.0+ |
❮ PHP ဖိုင်စနစ် အကိုးအကား