ขอ สคลิป การบันทึกข้อมูล ลง Text file หน่อยได้มะครับ
Moderators: mindphp, ผู้ดูแลกระดาน
- whiteman20
- PHP Jr. Member
- Posts: 21
- Joined: 01/01/1970 7:00 am
ขอ สคลิป การบันทึกข้อมูล ลง Text file หน่อยได้มะครับ
ผม ขอ สคลิป การบันทึกข้อมูล ลง Text file หน่อยได้มะครับ คือ ผมอยากทราบว่าจะต้องใช้สคลิป
อะไรบ้าง อย่างเช่น การกรอก Form แล้วให้ไปเก็บไว้ใน Text File แล้วสามารถมีการเรียกดู ข้อมูล ที่บันทึก ใน Text file ด้วยอ่ะครับ ถ้าไม่ลำบาก เกินไปขอรบกวนหน่อยครับ ไม่รู้จะไป พึ่งพาใครแล้ว T_T
อะไรบ้าง อย่างเช่น การกรอก Form แล้วให้ไปเก็บไว้ใน Text File แล้วสามารถมีการเรียกดู ข้อมูล ที่บันทึก ใน Text file ด้วยอ่ะครับ ถ้าไม่ลำบาก เกินไปขอรบกวนหน่อยครับ ไม่รู้จะไป พึ่งพาใครแล้ว T_T
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26692
- Joined: 22/09/2008 6:18 pm
- Contact:
ต้อง พึ่ง 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
- Posts: 21
- Joined: 01/01/1970 7:00 am
- whiteman20
- PHP Jr. Member
- Posts: 21
- Joined: 01/01/1970 7:00 am
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26692
- Joined: 22/09/2008 6:18 pm
- Contact:
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
- Posts: 26692
- Joined: 22/09/2008 6:18 pm
- Contact:
ถ้า 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
- Posts: 21
- Joined: 01/01/1970 7:00 am
-
- Similar Topics
- Replies
- Views
- Last post
-
-
ใครมีcode php แนะนำเกี่ยวกับ การ extract file pdf และ word เป็น text file บ้างคร
by beer_adisorn » 19/11/2011 11:25 am » in Programming - PHP - 4 Replies
- 2938 Views
-
Last post by beer_adisorn
22/11/2011 9:54 pm
-
-
- 4 Replies
- 1845 Views
-
Last post by 333822
26/06/2011 8:59 am
-
-
โปรแกรมที่เอาไว้เปิด text file ขนาดใหญ่ขนาด 50GB
by jataz2 » 03/07/2019 2:31 pm » in ถาม - ตอบ คอมพิวเตอร์ - 0 Replies
- 1136 Views
-
Last post by jataz2
03/07/2019 2:31 pm
-
-
-
ต้องการ upload file text มาแสดงโดยใช้ภาษา python เป็น web app
by patsa » 07/07/2015 10:14 am » in Programming - C/C++ & java & Python - 0 Replies
- 535 Views
-
Last post by patsa
07/07/2015 10:14 am
-
-
-
ข้อโค้ด C++ เขียนให้มัน load data จาก text file เก็บในรูปแบบของ list ยังไงอะค
by eroieroieroi » 19/11/2011 7:35 pm » in Programming - C/C++ & java & Python - 0 Replies
- 1717 Views
-
Last post by eroieroieroi
19/11/2011 7:35 pm
-
-
-
อ่าน text file แบบ real time ไม่ต้องกด reload เมื่อไฟล์ change
by jataz2 » 02/07/2019 10:15 am » in Programming - C/C++ & java & Python - 1 Replies
- 511 Views
-
Last post by jataz2
03/07/2019 10:39 am
-
Who is online
Users browsing this forum: No registered users and 11 guests