用PHP替换文件内容
问题描述:
我需要一个像 preg_replace 的函数,而不是字符串I需要它来处理文件/文件内容。
I need a function just like preg_replace but instead of strings I need it to work with files / file content.
答
您可以这样做:
$file = 'filename';
file_put_contents($file,str_replace('find','replace',file_get_contents($file)));