1 頁 (共 1 頁)

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

發表於 : 2007-06-27 14:59:27
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>