php 给文件尾部增加内容
如果我们想添加到一个文件,我们需要以追加方式打开它,下面的代码实现了这个功能,代码如下:
$text = "test.txt" ; if ( file_exists ( $text ) && is_file ( $text ) ) { $fh = fopen ( $myFile , 'a' ); if ( $fh ) { $stringData = "New www.phpfensi.com 1 " ; if ( fwrite( $fh , $stringData )) { echo '增加' . $stringData . '成功' ; } else { die ( '文件不可写' ); } $stringData = "New phpfensi.com 2 " ; fwrite( $fh , $stringData ); fclose( $fh ); } }查看更多关于php 给文件尾部增加内容 - php文件操作的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did27795