问题描述
我的文件夹包含大约500个文件(html)。每个文件都包含这个脚本
< script type =text / javascript><! -
google_ad_client =??????;
/ * unit1 * /
google_ad_slot =??????;
google_ad_width = 120;
google_ad_height = 90;
// - >
< / script>
我想用这个替换上面的代码
< script type =text / javascriptsrc =/ wp-content / themes / twentyfourteen / open.js>< / script>
我用这个代码>>很好
这只能在PHP中找到并替换,而不能在HTML中找到并替换。
任何人都可以找到并替换html文件?
不是我们在这里做什么,但我会如果(is_file($ path)&& substr($ path,-3),那么你可能会改变第17行:
)=='php'&& substr($ path,-17)!='ChangePHPText.php'){
$ ($ path)&& substr($ path,-4)b $ b
=='html'&& substr($ path,-17)!='ChangePHPText.php'){
虽然说实话,如果你做了很多的文本更改,你可能会发现一个文本编辑器,可以在文件中进行字符串替换,速度更快。
My folder contains about 500 files (html).Each files contain this script
<script type="text/javascript"><!--
google_ad_client = "??????";
/* unit1 */
google_ad_slot = "??????";
google_ad_width = 120;
google_ad_height = 90;
//-->
</script>
I want to replace above code with this
<script type="text/javascript" src="/wp-content/themes/twentyfourteen/open.js"></script>
I used this code >>is good
This find and replace in php only but no find and replace in html.Can anyone make it find and replace in html files?
Not really what we do here, but I would think you would just change line 17:
if( is_file( $path ) && substr($path, -3)=='php' && substr($path, -17) != 'ChangePHPText.php'){
to
if( is_file( $path ) && substr($path, -4)=='html' && substr($path, -17) != 'ChangePHPText.php'){
Though honestly, if you're doing that much text change, you may find a text editor that does string replacement in files to be much faster.
这篇关于使用PHP查找并替换多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!