当前位置:澳门新葡亰登入 > 热门新闻 > 全文搜索和替换

全文搜索和替换

文章作者:热门新闻 上传时间:2020-05-08

?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

本文由澳门新葡亰登入发布于热门新闻,转载请注明出处:全文搜索和替换

关键词: