你可以在fopen()函数中使用a或a +模式将数据追加到文件中。让我们看一个简单的示例, 将数据附加到data.txt文件中。
首先来看文件的数据。
data.txt
welcome to php file write
PHP附加到文件-fwrite()
PHP fwrite()函数用于将数据写入文件并附加到文件中。
例子
<?php
$fp = fopen('data.txt', 'a');//opens file in append mode
fwrite($fp, ' this is additional text ');
fwrite($fp, 'appending data');
fclose($fp);
echo "File appended successfully";
?>
输出:data.txt
welcome to php file write this is additional text appending data
来源:
https://www.srcmini02.com/29138.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_38085.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57