如何自动删除txt消息?

时间:2016-12-19 15:30:19

标签: php

我想知道是否可以在30分钟后自动删除邮件

chat.txt

没有我打开并清除它。我该怎么做?谢谢!

2 个答案:

答案 0 :(得分:0)

或许这样的事情:

//** path to file
$file = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];

//** check file age     
if (strtotime($file) > strtotime("-30 minutes")) {
  $fage = 'old';
  //** file is older -- do something
} else {
  $fage = 'new';
  //** file is NOT older -- do something else
}

//** print result
echo $fage;

答案 1 :(得分:0)

你需要配置" cron job"在你的主人... ... 1-你需要linux命令来运行php版本的玉米作业:
http://support.hostgator.com/articles/cpanel/what-do-i-put-for-the-cron-job-command
2-设定运行时间的时间。为30分钟并重复 - 设置 - > * / 30
3-创建" cron.php" file ...
并输入此代码..
file_put_contents(" file.txt","");

相关问题