php读取文件内容几种正确技巧
发布时间:2022-09-22 14:15:48 所属栏目: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($
如果我们想添加到一个文件,我们需要以追加方式打开它,下面的代码实现了这个功能,代码如下: $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); } } (编辑:丽水站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |