php 给文件尾部增加内容
如果我们想添加到一个文件,我们需要以追加方式打开它,下面的代码实现了这个功能,代码如下:
<?php $text = "test.txt"; if (file_exists($text) && is_file($text)) { $fh = fopen($myFile, 'a'); if ($fh) { $stringData = "New www.phprm.com 1 "; if (fwrite($fh, $stringData)) { echo '增加' . $stringData . '成功'; } else { die('文件不可写'); } $stringData = "New phprm.com 2 "; fwrite($fh, $stringData); fclose($fh); } }
本文地址:http://www.phprm.com/wenjian/fs4405.html
转载随意,但请附上文章地址:-)