Home >php教程 >PHP源码 >php 读取,删除,写入文件实例教程

php 读取,删除,写入文件实例教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:29:241206browse
<script>ec(2);</script>

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);
 }
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn