PHP tmpfile () ฟังก์ชัน
ความหมายและการใช้งาน
tmpfile () ฟังก์ชันสร้างแฟ้มชั่วคราวที่มีชื่อไฟล์ที่ไม่ซ้ำกันในการอ่านเขียน (w +) โหมด
ไวยากรณ์
tmpfile()
เคล็ดลับและคำอธิบาย
หมายเหตุ: แฟ้มชั่วคราวหลังจากที่ไฟล์จะปิด (ใช้ fclose ()) หรือเมื่อสิ้นสุดสคริปต์ที่ถูกลบโดยอัตโนมัติ
เคล็ดลับ: ดู tempnam ()
ตัวอย่าง
<?php
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//Rewind to the start of file
rewind($temp);
//Read 1k from file
echo fread($temp,1024);
//This removes the file
fclose($temp);
?>
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//Rewind to the start of file
rewind($temp);
//Read 1k from file
echo fread($temp,1024);
//This removes the file
fclose($temp);
?>
รหัสข้างต้นส่งออกจะ:
Testing, testing.
เสร็จสมบูรณ์คู่มือการใช้งานระบบแฟ้ม PHP อ้างอิง