|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
<?php exec("/bin/grep -r \\'$oldword\\' $rootpath", $results, $errorCode); if ($errorCode){ if ($errorCode == 1){ echo "Possibly no files were found with $oldword in them<BR>n"; } echo "OS Error: $errorCode<BR>n"; echo "Check \\'man errno\\' and count down<BR>n"; echo "Usually paths/permissions<BR>n"; } while (list(,$path) = each($results)){ $parts = explode(\\':\\', $path); $path = $parts[0]; $fp = fopen($path, \\'r\\') or print("Cannot read $path<BR>n"); if ($fp){ $data = fread($fp, filesize($path)); fclose($fp); $newdata = str_replace($oldword, $newword, $data); $fp = fopen($path, \\'w\\') or print("Cannot write $path<BR>n"); if ($fp){ fwrite($fp, $newdata); fclose($fp); echo $path, "<BR>n"; } } } ?> Example http://yourserver.com/globalreplace.php?oldword=test&newword=text&rootpath=/path/to/dir 返回类别: 教程 上一教程: PHP编程网上游 下一教程: PHP 5.0对象模型深度探索之属性和方式 您可以阅读与"全文搜索和替换"相关的教程: · PHP文本数据库的搜索方式 · 搜索引擎技术核心揭密 · PHP源码学习:站内搜索HTML版 · 根据来路是否为搜索引擎来决定是否跳出弹窗代码 · 搜索引擎技术核心揭密(PHP) |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |