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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBoriginal
2016-06-08 17:29:241203parcourir
<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);
 }
}

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn