【发布时间】:2012-04-04 06:42:35
【问题描述】:
我想通过在我的项目文件夹和子文件夹文件中的所有 php 和其他文件中将其替换为空格来更改一些代码。 我有以下代码。
if ($handle = @ opendir("for testing")) {
while (($entry = readdir($handle)) ) {
if ($entry != "." && $entry != "..") {
$linecop = '/*god_mode_on*eval(test("ZXkViKSk7IA=="));*god_mode_off*/';
$homepage = file_get_contents($entry);
$string3=str_replace($linecop,'',$homepage);
$file = fopen($entry, "w") or exit("Unable to open file!");
fwrite($file, $string3);
fclose($file); //
}
}
closedir($handle);
}
但此代码仅适用于一个文件。如何更改所有文件?
【问题讨论】:
-
这里是代码 if ($handle = @ opendir("for testing")) { while (($entry = readdir($handle)) ) { if ($entry != "." && $entry != "..") { $linecop = '/*god_mode_on*eval(test("ZXkViKSk7IA=="));*god_mode_off*/'; $homepage = file_get_contents($entry); $string3=str_replace($linecop,'',$homepage); $file = fopen($entry, "w") 或 exit("无法打开文件!"); fwrite($file, $string3); fclose($文件); // } } closeir($handle); }
标签: php file-handling