当前位置:首页 > 技术分享 > 正文内容

php 文件追加内容

admin10个月前 (01-20)技术分享866

1.尾部追加

 $fp = fopen($file, 'a');
 fwrite($fp, $content."\n");
 fclose($fp);


2.头部追加

// 打开文件
$fileHandle = fopen($file, 'r+');
// 读取文件内容到字符串
$fileSize = filesize($file);
$content = fread($fileHandle, $fileSize);
// 移动文件指针到文件开头
fseek($fileHandle, 0);
// 写入新内容
fwrite($fileHandle, $contentToAdd."\n");
fwrite($fileHandle, $content);
// 关闭文件
fclose($fileHandle);


扫描二维码推送至手机访问。

版权声明:本文由小刚刚技术博客发布,如需转载请注明出处。

本文链接:https://blog.bitefu.net/post/644.html

标签: php
分享给朋友:

相关文章

php高效检测远程图片是否存在

php高效检测远程图片是否存在function img_exits($url){     $ch = curl_init();    &...

[Windows] Adobe Flash Player 34.0.0.92及可用版修改方法

[Windows] Adobe Flash Player 34.0.0.92及可用版修改方法

随着 2021 年的到来,Adobe Flash Player 也迎来了告别,Adobe 在 2020 年 12 月 31 日后将不再支持 Flash Player。其实早在 2017 年,Adobe 公司就已宣布,计划在 2020 年底逐...

php Aes 加密模式ECB填充pkcs5padding base64

最近做支付项目用到了aes加密不过试了好多办法总是和官方给出的结果不一样,找了很久终于找到了测试结果同 http://tool.chacuo.net/cryptaes/ <?php /**  * [Aes&nb...

安卓模拟器连接端口 及常用命令

下面是我总结和测试通过的:有的是搜集来的模拟器名称                     &nbs...

Chrome 最全历史版本下载以及chromedriver下载

https://vikyd.github.io/download-chromium-history-version/#/ https://dl.lancdn.com/landian/soft/chrome/m/ chromedriver的版...

python3 selenium webdriver.Chrome php 爬取汽车之家所有车型详情数据[开源版]

介绍本接口是车型库api的补充,用于爬取汽车之家所有车型详情数据开源地址:https://gitee.com/web/CarApi/tree/master/python软件架构python3 selenium webdriver.Chrom...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。