我正在处理应该替换另一个文件中的变量的文件。到目前为止,我尝试过:我可以在另一个文件中替换吗?
$File = "$dir/submit.php";
$fh = fopen($File, 'r') or die("Couldn't edit the Config-file. Please report to admin.");
$chosendb = str_replace('$chosendb = comments;','$chosendb = wuhuws_$dir;','$chosendb');
fclose($fh);
$ dir是一个用户输入。 注释是数据库中需要用prefix_ $ dir替换的表。
我该怎么做?
你甚至还没有从文件中读取。你只是打开了一个句柄。 [使用'file_get_contents()'](http://us3.php.net/manual/en/function.file-get-contents.php)将其读入字符串。然而,看到@zerkms这不是一个好主意,开始... –
@zerkms,应*不* *! – bfavaretto
@zerkms怎么回事? :) – Christian