有一个文件123.php,要用php怎么实现替换它里面的内容,是全部替换。 首先整两个文件:123.php、test.php 123.php: <?php '我是123'; ?> test.php: <?php $content =file_get_contents('123.php'); //复杂替换可以考虑使用正则。 $content = str_replace('我是123','我也是123',$content); file_put_contents('123.php',$content); ?> 运行test.php之后,123.php 内容就会更改成我也是123 |
|