教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php 写入和读取文件函数

php 写入和读取文件函数

发布时间:2017-10-23   编辑:jiaochengji.com
教程集为您提供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 写入和读取文件函数
php 文件系统处理 fopen
学习php读取文件内容的方法
php读取文件的方法
解决php csv文件导入mysql中文乱码
php文件的读写操作
php的readfile能读图片吗
PHP如何处理文件权限?(代码示例)
二种php生成html页面实现代码

[关闭]
~ ~