2011-09-17 41 views

回答

1

這裏是用PHP來打開一個PHP文件中的代碼:

$file = "/home/dir/file.php"; 
$fs = fopen($file, "a+") or die("error when opening the file"); 
while (!feof($fs)) { 
$contents .= fgets($fs, 1024); 
} 
fclose($fs); 

現在你可以走了$contents,並修改它,但是你想,然後保存。這裏是如何保存它:

$fs = fopen($_POST["file"], "a+") or die("error when opening the file"); 

fwrite($fs, $updatedContents); 

fclose(); 

$updatedContents是更新內容

+0

哇,完美的幫助.. A +,謝謝 –

+0

謝謝,我將不勝感激它,你可以選擇我的答案和/或投票,如果它幫助你解決你的問題 – ahoura

+0

自修改代碼有它自己的一套問題,除非你'準備好解決它們,你應該避免它。 –

1

不,你不知道。將該值放入外部源(平面文件或數據庫)中,然後讀取a.php中的值。

+0

沒關係,幫忙感謝。 –

相關問題