使用php清除文本文件的内容 [英] Clearing content of text file using php

查看:106
本文介绍了使用php清除文本文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个filelist.txt文件

并且我创建了clear.php文件来清除文件列表的内容

在index.html中,我放了一个按钮来调用clear.php来清除



任何人都可以帮我解决:



我应该在clear.php中写什么php代码



如何编写一个按钮来调用clear.php,然后返回到index.html,显示结果它已被清除?



谢谢

解决方案

   file_put_contents (filelist。 txt,);  

您可以使用 header()函数修改位置标题。


I have a filelist.txt file

and i create clear.php file to clear the content of filelist

in index.html i put a button to call clear.php to clear

Can anyone help me out regarding:

What php code should i write in clear.php

How to code a button to call clear.php and then return back to index.html showing the result that it has been cleared?

Thank You

解决方案

file_put_contents("filelist.txt", "");

You can redirect by using the header() function to modify the Location header.

这篇关于使用php清除文本文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆