澳门新葡萄京官网注册全文搜索和替换

?php exec(“/bin/grep -r $oldword $rootpath”, $results, $errorCode); if
($errorCode){ if ($errorCode == 1){ echo “Possibly no files were found
with $oldword in themBR”; } echo “OS Error: $errorCodeBR”; echo “Check
man errno and count downBR”; echo “Usually paths/permissionsBR”; } while
(list(,$path) = each($results)){ $parts = explode(:, $path); $path =
$parts[0]; $fp = fopen($path, r) or print(“Cannot read $pathBR”); if
($fp){ $data = fread($fp, filesize($path)); fclose($fp); $newdata =
str_replace($oldword, $newword, $data); $fp = fopen($path, w) or
print(“Cannot write $pathBR”); if ($fp){ fwrite($fp, $newdata);
fclose($fp); echo $path, “BR”; } } } ? Example
?oldword=testnewword=textrootpath=/path/to/dir

发表评论

电子邮件地址不会被公开。 必填项已用*标注