PHP ကျူတိုရီရယ်

PHP ပင်မစာမျက်နှာ PHP မိတ်ဆက် PHP ထည့်သွင်းပါ။ PHP Syntax PHP မှတ်ချက်များ PHP Variables များ PHP Echo / Print PHP Data အမျိုးအစားများ PHP စာတန်းများ PHP နံပါတ်များ PHP သင်္ချာ PHP Constants PHP Operator များ PHP If...Else...Elseif PHP Switch PHP Loops PHP လုပ်ဆောင်ချက်များ PHP Arrays PHP Superglobals PHP RegEx

PHP Forms

PHP Form ကိုင်တွယ်ခြင်း။ PHP Form Validation PHP Form လိုအပ်ပါသည်။ PHP Form URL/E-mail PHP Form ပြီးပါပြီ။

PHP အဆင့်မြင့်

PHP နေ့စွဲနှင့် အချိန် PHP ပါဝင်ပါတယ်။ PHP ဖိုင်ကိုင်တွယ်ခြင်း PHP ဖိုင်ကို ဖွင့်/ဖတ်ပါ။ PHP ဖိုင်ကို ဖန်တီး/ရေးပါ။ PHP ဖိုင်ကို တင်ခြင်း။ PHP Cookies PHP စက်ရှင်များ PHP Filters PHP Filters Advanced PHP ပြန်ခေါ်ခြင်းလုပ်ဆောင်ချက်များ PHP JSON PHP ခြွင်းချက်

PHP OOP

PHP OOP ဆိုတာဘာလဲ PHP အတန်းများ/အရာဝတ္ထုများ PHP Constructor PHP Destructor PHP Access Modifiers PHP Inheritance PHP Constants PHP Abstract အတန်းများ PHP မျက်နှာပြင်များ PHP လက္ခဏာများ PHP Static Methods PHP Static Properties PHP Namespaces PHP Iterables

MySQL ဒေတာဘေ့စ်

MySQL ဒေတာဘေ့စ် MySQL ချိတ်ဆက်မှု MySQL သည် DB ကိုဖန်တီးပါ။ MySQL ဇယားဖန်တီးပါ။ MySQL သည် Data ကိုထည့်သွင်းပါ။ MySQL နောက်ဆုံး ID ကိုရယူပါ။ MySQL တွင် Multiple ထည့်သွင်းပါ။ MySQL ပြင်ဆင်ထားသည်။ MySQL Data ကို ရွေးပါ။ MySQL ဘယ်မှာလဲ။ MySQL Order By MySQL က Data တွေကို ဖျက်လိုက်ပါ။ MySQL အပ်ဒိတ်ဒေတာ MySQL ကန့်သတ်ဒေတာ

PHP XML

PHP XML ပါဆာများ PHP SimpleXML Parser PHP SimpleXML - ရယူပါ။ PHP XML Expat PHP XML DOM

PHP - AJAX

AJAX နိဒါန်း AJAX PHP AJAX ဒေတာဘေ့စ် AJAX XML AJAX တိုက်ရိုက်ရှာဖွေမှု AJAX စစ်တမ်း

PHP ဥပမာများ

PHP ဥပမာများ PHP Compiler PHP Quiz PHP လေ့ကျင့်ခန်းများ PHP Certificate

PHP အ ကိုးအကား

PHP ခြုံငုံသုံးသပ်ချက် PHP Array PHP ပြက္ခဒိန် PHP နေ့စွဲ PHP လမ်းညွှန် PHP အမှား PHP ခြွင်းချက် PHP ဖိုင်စနစ် PHP Filter PHP FTP PHP JSON PHP သော့ချက်စာလုံးများ PHP Libxml PHP Mail PHP သင်္ချာ PHP ထွေ PHP MySQLi PHP ကွန်ရက် PHP Output Control PHP RegEx PHP SimpleXML PHP Stream PHP String PHP Variable ကိုင်တွယ်ခြင်း။ PHP XML Parser PHP Zip PHP အချိန်ဇုန်များ

PHP ဖိုင်ကို ဖွင့်/ဖတ်/ပိတ်ပါ။


ဤအခန်းတွင် ဆာဗာပေါ်တွင် ဖိုင်တစ်ဖိုင်ကို ဖွင့်ခြင်း၊ ဖတ်ခြင်းနှင့် ပိတ်နည်းကို သင်ပေးပါမည်။


PHP Open File - fopen()

ဖိုင်များကိုဖွင့်ရန် ပိုမိုကောင်းမွန်သောနည်းလမ်းမှာ fopen()လုပ်ဆောင်ချက်ဖြင့်ဖြစ်သည်။ ဤလုပ်ဆောင်ချက်သည် သင့်အား လုပ်ဆောင်ချက်ထက် ရွေးချယ်စရာများ ပိုမိုပေးသည် readfile()

သင်ခန်းစာများအတွင်း ကျွန်ုပ်တို့သည် စာသားဖိုင်၊ "webdictionary.txt" ကို အသုံးပြုပါမည်-

AJAX = Asynchronous JavaScript and XML
CSS = Cascading Style Sheets
HTML = Hyper Text Markup Language
PHP = PHP Hypertext Preprocessor
SQL = Structured Query Language
SVG = Scalable Vector Graphics
XML = EXtensible Markup Language

ပထမဘောင် fopen()တွင် ဖွင့်ရမည့်ဖိုင်အမည်ပါရှိပြီး ဒုတိယဘောင်သည် မည်သည့်မုဒ်တွင် ဖိုင်ကိုဖွင့်သင့်သည်ကို သတ်မှတ်သည်။ fopen() လုပ်ဆောင်ချက်သည် သတ်မှတ်ထားသောဖိုင်ကို မဖွင့်နိုင်ပါက အောက်ပါဥပမာသည် စာတိုတစ်စောင်ကိုလည်း ထုတ်ပေးသည်-

ဥပမာ

<?php
$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("webdictionary.txt"));
fclose($myfile);
?>

အကြံပြုချက်- ၎င်း fread()နှင့် fclose()လုပ်ဆောင်ချက်များကို အောက်တွင် ရှင်းပြပါမည်။

ဖိုင်ကို အောက်ပါမုဒ်များထဲမှ တစ်ခုဖြင့် ဖွင့်နိုင်သည်-

Modes Description
r Open a file for read only. File pointer starts at the beginning of the file
w Open a file for write only. Erases the contents of the file or creates a new file if it doesn't exist. File pointer starts at the beginning of the file
a Open a file for write only. The existing data in file is preserved. File pointer starts at the end of the file. Creates a new file if the file doesn't exist
x Creates a new file for write only. Returns FALSE and an error if file already exists
r+ Open a file for read/write. File pointer starts at the beginning of the file
w+ Open a file for read/write. Erases the contents of the file or creates a new file if it doesn't exist. File pointer starts at the beginning of the file
a+ Open a file for read/write. The existing data in file is preserved. File pointer starts at the end of the file. Creates a new file if the file doesn't exist
x+ Creates a new file for read/write. Returns FALSE and an error if file already exists


PHP Read File - fread()

လုပ်ဆောင်ချက်သည် အ fread()ဖွင့်ဖိုင်တစ်ခုမှ ဖတ်သည်။

၏ပထမဘောင် fread()တွင်ဖတ်ရန်ဖိုင်အမည်ပါရှိပြီးဒုတိယဘောင်သည်ဖတ်ရန်အများဆုံးဘိုက်အရေအတွက်ကိုသတ်မှတ်သည်။

အောက်ပါ PHP ကုဒ်သည် "webdictionary.txt" ဖိုင်ကို အဆုံးအထိ ဖတ်ပြသည်-

fread($myfile,filesize("webdictionary.txt"));

PHP Close File - fclose()

ဖွင့် ထားသော fclose()ဖိုင်ကိုပိတ်ရန် function ကိုအသုံးပြုသည်။

၎င်းတို့နှင့် ပြီးပါက ဖိုင်များအားလုံးကို ပိတ်ရန် ပရိုဂရမ်ရေးဆွဲခြင်း အလေ့အကျင့်ကောင်းတစ်ခု ဖြစ်ပါသည်။ သင့်ဆာဗာပေါ်တွင် အရင်းအမြစ်များကို ထုတ်ယူနေသည့် ပွင့်လင်းဖိုင်ကို သင်မလိုချင်ပါ။

fclose()ကျွန်ုပ်တို့ပိတ်လိုသော ဖိုင်အမည် (သို့မဟုတ် ဖိုင်အမည်ကို ကိုင်ဆောင်ထားသော ကိန်းရှင်တစ်ခု) လိုအပ်သည် -

<?php
$myfile = fopen("webdictionary.txt", "r");
// some code to be executed....
fclose($myfile);
?>

PHP တစ်ကြောင်းတည်းဖတ်ပါ - fgets()

fgets()ဖိုင်တစ်ခုမှ စာကြောင်းတစ်ကြောင်းကို ဖတ်ရန် လုပ်ဆောင်ချက်ကို အသုံးပြုသည်

အောက်ပါဥပမာသည် "webdictionary.txt" ဖိုင်၏ ပထမစာကြောင်းကို ထုတ်ပေးသည်-

ဥပမာ

<?php
$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
echo fgets($myfile);
fclose($myfile);
?>

မှတ်ချက်fgets()_


PHP Check End-of-File - feof()

function သည် feof()"end-of-file" (EOF) သို့ရောက်ရှိခြင်းရှိမရှိစစ်ဆေးသည်။

အဆိုပါ feof()လုပ်ဆောင်ချက်သည် အမည်မသိ အရှည်ရှိသော အချက်အလက်များကို လှည့်ပတ်ခြင်းအတွက် အသုံးဝင်သည်။

အောက်ဖော်ပြပါ ဥပမာသည် "webdictionary.txt" ဖိုင်ကို ဖိုင်အဆုံးအထိ ရောက်သည်အထိ တစ်ကြောင်းပြီးတစ်ကြောင်း ဖတ်သည်-

ဥပမာ

<?php
$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
// Output one line until end-of-file
while(!feof($myfile)) {
  echo fgets($myfile) . "<br>";
}
fclose($myfile);
?>

PHP Read Single Character - fgetc()

fgetc()ဖိုင်တစ်ခုမှ စာလုံးတစ်လုံးကို ဖတ်ရန် လုပ်ဆောင်ချက်ကို အသုံးပြုသည်

အောက်ဖော်ပြပါ ဥပမာသည် ဖိုင်၏အဆုံးသို့မရောက်မချင်း "webdictionary.txt" ဖိုင်ကို အက္ခရာစာလုံးအလိုက် ဖတ်ပြသည်-

ဥပမာ

<?php
$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
// Output one character until end-of-file
while(!feof($myfile)) {
  echo fgetc($myfile);
}
fclose($myfile);
?>

မှတ်ချက်fgetc()_


PHP Filesystem Reference ကို ပြီးအောင်လုပ်ပါ။

ဖိုင်စနစ်လုပ်ဆောင်ချက်များကို အပြည့်အစုံကိုးကားရန်အတွက်၊ ကျွန်ုပ်တို့၏ ပြီးပြည့်စုံသော PHP Filesystem Reference သို့ သွားပါ ။


PHP လေ့ကျင့်ခန်းများ

လေ့ကျင့်ခန်းများဖြင့် သင့်ကိုယ်သင် စမ်းသပ်ပါ။

လေ့ကျင့်ခန်း

ဖိုင်တစ်ခုကိုဖွင့်ပြီး ဖိုင်အဆုံးအထိ တစ်ချိန်တည်းတွင် စာလုံးတစ်လုံးထွက်ရန် မှန်ကန်သော syntax ကိုရေးပါ။

$myfile = fopen("webdict.txt", "r");
while(!($myfile)) {
  echo ($myfile);
}