php 文件保存函数,php 写入和读取文件函数
生活随笔
收集整理的這篇文章主要介紹了
php 文件保存函数,php 写入和读取文件函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//讀取文件函數
function readfromfile($file_name) {
if (file_exists($file_name)) {
$filenum=fopen($file_name,"r");
flock($filenum,lock_ex);
$file_data=fread($filenum, filesize($file_name));
rewind($filenum); //osphp.com.cn
fclose($filenum);
return $file_data;
}
}
?>
//寫入文件函數
function writetofile($file_name,$data,$method="w") {
$filenum=fopen($file_name,$method);
flock($filenum,lock_ex);
$file_data=fwrite($filenum,$data);
fclose($filenum);
return $file_data;
}
?>
總結
以上是生活随笔為你收集整理的php 文件保存函数,php 写入和读取文件函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 抽象类_什么是final?Ja
- 下一篇: php如何实现购物时数量增减,1、vue