ผม ขอ สคลิป การบันทึกข้อมูล ลง Text file หน่อยได้มะครับ คือ ผมอยากทราบว่าจะต้องใช้สคลิป
อะไรบ้าง อย่างเช่น การกรอก Form แล้วให้ไปเก็บไว้ใน Text File แล้วสามารถมีการเรียกดู ข้อมูล ที่บันทึก ใน Text file ด้วยอ่ะครับ ถ้าไม่ลำบาก เกินไปขอรบกวนหน่อยครับ ไม่รู้จะไป พึ่งพาใครแล้ว T_T
ขอ สคลิป การบันทึกข้อมูล ลง Text file หน่อยได้มะครับ
Moderator: mindphp, ผู้ดูแลกระดาน
- whiteman20
- PHP Jr. Member
- โพสต์: 21
- ลงทะเบียนเมื่อ: 01/01/1970 7:00 am
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41232
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
ต้อง พึ่ง function ที่ php มีอยู่ ล่ะครั บ
ถ้าเอา แบบ ง่ายๆ สุด แบบ php 5 ก็
file_put_contents ( string filename, mixed data )
โดยที่ string filename คือ ชื่อไฟล์ที่เราต้อง การเขียน
mixed data คือ ข้อความ ของ เรา ที่ จะเขียนลงไป ครับ
ส่วนการอ่าน ข้อมูล จากไฟล์ ก็
file_get_contents ( string filename)
จะคือ ค่าออกมาเป็น string ครับ
ถ้าเอา แบบ ง่ายๆ สุด แบบ php 5 ก็
file_put_contents ( string filename, mixed data )
โดยที่ string filename คือ ชื่อไฟล์ที่เราต้อง การเขียน
mixed data คือ ข้อความ ของ เรา ที่ จะเขียนลงไป ครับ
ส่วนการอ่าน ข้อมูล จากไฟล์ ก็
file_get_contents ( string filename)
จะคือ ค่าออกมาเป็น string ครับ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
- whiteman20
- PHP Jr. Member
- โพสต์: 21
- ลงทะเบียนเมื่อ: 01/01/1970 7:00 am
- whiteman20
- PHP Jr. Member
- โพสต์: 21
- ลงทะเบียนเมื่อ: 01/01/1970 7:00 am
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41232
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
file_get_contents ใช้ได้กับ php 4.3 เป็นต้นมา ครับ
แต่
file_put_contents ใช้ได้กับ php5 นะครับ
แต่
file_put_contents ใช้ได้กับ php5 นะครับ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41232
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
ถ้า php 4 จะเขียนไฟล์ ก็ ตามนี้นะครับ จากคู่มือ php
<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
- whiteman20
- PHP Jr. Member
- โพสต์: 21
- ลงทะเบียนเมื่อ: 01/01/1970 7:00 am
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
-
โพสต์ใหม่ โปรแกรมที่เอาไว้เปิด text file ขนาดใหญ่ขนาด 50GB
โดย jataz2 » 03/07/2019 2:31 pm » ใน ถาม - ตอบ คอมพิวเตอร์ - 0 ตอบกลับ
- 2806 แสดง
-
โพสต์ล่าสุด โดย jataz2
03/07/2019 2:31 pm
-
-
-
โพสต์ใหม่ ต้องการ upload file text มาแสดงโดยใช้ภาษา python เป็น web app
โดย patsa » 07/07/2015 10:14 am » ใน Programming - C/C++ & java & Python - 0 ตอบกลับ
- 888 แสดง
-
โพสต์ล่าสุด โดย patsa
07/07/2015 10:14 am
-
-
-
โพสต์ใหม่ สอบถามวิธีการสร้าง tab delimited text file ด้วย python โดยไม่ต้อง save ลงเครื่องค่ะ
โดย MBMoo » 08/12/2023 4:45 pm » ใน Programming - C/C++ & java & Python - 3 ตอบกลับ
- 5237 แสดง
-
โพสต์ล่าสุด โดย mindphp
08/12/2023 5:17 pm
-
-
-
โพสต์ใหม่ อ่าน text file แบบ real time ไม่ต้องกด reload เมื่อไฟล์ change
โดย jataz2 » 02/07/2019 10:15 am » ใน Programming - C/C++ & java & Python - 1 ตอบกลับ
- 1062 แสดง
-
โพสต์ล่าสุด โดย jataz2
03/07/2019 10:39 am
-
-
-
โพสต์ใหม่ Python GUI (Tkinter) : การ Browse file แบบ multiple file จากการกดปุ่ม Button
โดย benzas00123 » 30/01/2020 5:46 pm » ใน Python Knowledge - 0 ตอบกลับ
- 1862 แสดง
-
โพสต์ล่าสุด โดย benzas00123
30/01/2020 5:46 pm
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 112