php 读取,删除,写入文件实例教程
//-------------------------------删除文件
function delfiletext($filename){
@unlink($filename);
}
//---------------------------------取得文件内容
function readfiletext($filepath){
$htmlfp=@fopen($filepath,r);
while($data=@fread($htmlfp,1000))
{
$string.=$data;
}
@fclose($htmlfp);
return $string;
}
//--------------------------------写文件
function writefiletext($filepath,$string){
global $filechmod;
$string=stripslashes($string);
$fp=@fopen($filepath,w);
@fputs($fp,$string);
@fclose($fp);
if(empty($filechmod))
{
@chmod($filepath,0777);
}
}
//--------------------------------写文件
function writefiletext_n($filepath,$string){
global $filechmod;
$fp=@fopen($filepath,w);
@fputs($fp,$string);
@fclose($fp);
if(empty($filechmod))
{
@chmod($filepath,0777);
}
}