|  | การประมวลผลแฟ้มแบบ text |  | 
| ข้อควรทราบ | 
| 
 | 
| สร้างแฟ้มพร้อมเพิ่มระเบียนแรก (ไม่ว่าในแฟ้มจะมีอะไร จะหายหมด เหลือแค่ระเบียนใหม่ 1 ระเบียนเท่านั้น) http://www.se-ed.net/thaiall/fopenw.php3 | 
| 
 | 
<?
$today = getdate();
$hour = $today[hours];
$minutes = $today[minutes];
$seconds = $today[seconds];
$file = fopen("fsample.txt","w");
fputs($file , "$hour $minutes $seconds <br>\n");
fclose($file);
print "save $hour $minutes $seconds ok";
?>
 | 
| สร้างแฟ้ม หรือเพิ่มระเบียนต่อท้าย (ถ้าไม่มีแฟ้มก็จะสร้างแฟ้ม แต่ถ้ามีแล้วจะนำระเบียนไปต่อท้าย) http://www.se-ed.net/thaiall/fopena.php3 | 
| 
 | 
<?
$today = getdate();
$hour = $today[hours];
$minutes = $today[minutes];
$seconds = $today[seconds];
$file = fopen("fsample.txt","a");
fputs($file , "$hour $minutes $seconds <br>\n");
fclose($file);
print "save append $hour $minutes $seconds ok<br>";
?>
 | 
| อ่านข้อมูลจากแฟ้ม มาแสดงทางจอภาพ (อ่านข้อมูลมาแสดง) http://www.se-ed.net/thaiall/fget.php3 | 
| 
 | 
<?
$file = fopen("fsample.txt","r");
while (!feof($file)) {
 $buffer = fgets($file,4096);
 echo $buffer;
}
?>
 | 
| ฟอร์ม html ที่ใช้เลือกระเบียนที่ต้องการลบ (รับค่าจากแป้นพิมพ์ แล้วส่งไปให้ php กระทำ) http://www.se-ed.net/thaiall/fsndvalue.htm | 
| 
 | |
| thaiallvalue=wowfromurl fget.php3 fopena.php3 fdelrec.php3 fopenasndvalue.php3 fopenw.php3 fsample.txt | <body> <form action=fopenasndvalue.php3>Add value <input name=thaiallvalue> <input type=submit value=fopenasndvalue.php3> </form> <a href=fopenasndvalue.php3?thaiallvalue=wowfromurl>thaiallvalue=wowfromurl</a> <hr> <form action=fdelrec.php3>Delete record number <input name=recn> <input type=submit value=fdelrec.php3> </form> <hr> <a href=fget.php3>fget.php3</a><br> <a href=fopena.php3>fopena.php3</a><br> <a href=fdelrec.php3>fdelrec.php3</a><br> <a href=fopenasndvalue.php3>fopenasndvalue.php3</a><br> <a href=fopenw.php3>fopenw.php3</a><br> <a href=fsample.txt>fsample.txt</a><br> <hr> </body> | 
| โปรแกรมที่รับค่าจากฟอร์มไปเพิ่มในแฟ้ม (รับค่าจากฟอร์ม แล้ว เพิ่มค่าต่อท้ายแฟ้มเดิม) http://www.se-ed.net/thaiall/fopenasndvalue.php3 | 
| 
 | 
<?
$file = fopen("fsample.txt","a");
fputs($file , "$thaiallvalue<br>\n");
fclose($file);
print "save append from input $thaiallvalue ok<br>";
?>
 | 
| ลบระเบียน ตามลำดับเลขระเบียน (ทำหน้าที่ลบระเบียนที่ต้องการ โดยรับเลขระเบียนจากฟอร์ม) http://www.se-ed.net/thaiall/fdelrec.php3 | 
| 
 | 
<?
$filer = fopen("fsample.txt","r");
$i = 1;
while (!feof($filer)) {
 $buffer[$i] = fgets($filer,4096);
 $i++;
}
$total = $i;
fclose($filer);
$filew = fopen("fsample.txt","w");
$i = 1;
while  ($i < $total) {
 if ($i <> $recn) {  fputs($filew , "$buffer[$i]"); }
 $i++;
}
fclose($filew);
print "Delete ok <hr>ข้อมูลหลังลบแล้ว<br>";
$file = fopen("fsample.txt","r");
while (!feof($file)) {
 $buffer = fgets($file,4096);
 echo $buffer;
}
?>
 | 
| แบบฝึกหัด | 
| 
 | 
|  | + ผู้สนับสนุน + รับผู้สนับสนุน |