用PHP替换文件内容 [英] Replacing file content in PHP

查看:141
本文介绍了用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)));

这篇关于用PHP替换文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆