用php替換檔案裡的某些字串

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

用php替換檔案裡的某些字串

文章 yehlu »

<?

function phpfileedit($file){
$add = 0;
echo $file."<br>";
$fp = fopen("$file","r+");
$old = fread($fp,filesize($file));
$new1 = str_replace('old','new',$old);
$new2 = str_replace('old1','new1',$new1);
$new3 = str_replace('old2','new2',$new2);
$new = str_replace('old3','new3',$new3);
fclose($fp);
$fp1 = fopen("$file","w+");
fwrite($fp1,$new);
fclose($fp1);
}


function ListDir($dir){
echo "<UL>";
$handle = opendir($dir);
while ($sdir=readdir($handle)){
if(is_dir("$dir/$sdir") and $sdir<> "." and $sdir</UL>
回覆文章

回到「PHP」