Loading... ```shell <?php //获取网址参数 $post = $_REQUEST['post']; //指定文件 $filename= $_REQUEST['chi']; $filename= "$filename.txt"; //判断文件是否存在 if(file_exists("$filename")) { //如果存在 获取文件内容 $content = file_get_contents($filename); //对比是否重复 if(strstr($content,$post)) { //如果重复输出重复 echo "no"; } else { //如果不重复 指向文件末尾 $handle=fopen($filename,"a+"); //追加写入不重复的参数内容 $str=fwrite($handle,"$post\r\n"); //关闭 fclose($handle); //输出可用 echo "ok"; } } else { //如果文件不存在 直接写入参数内容 $handle=fopen($filename,"a+"); $str=fwrite($handle,"$post\r\n"); //关闭 fclose($handle); //输出可用 echo "ok"; } ?> ``` ```shell //定时删除 //centos 每天0点 crontab -e 0 0 * * * rm -rf /文件目录/*.txt //windows 定时用计划任务调用 @echo off del *.txt exit ``` 最后修改:2020 年 12 月 29 日 05 : 19 AM © 允许规范转载 赞赏 如果觉得我的文章对你有用,请随意赞赏 ×Close 赞赏作者 扫一扫支付 支付宝支付 微信支付