douzhuang2570 2016-03-31 09:17
浏览 104

如何在修改.txt文件的内容时刷新我的.php站点

I have a .php file that displays a .txt from my FTP server to a webpage.

My problem is that I want to get the .php page to refresh when something is added to the .txt file.

Right now I'm using this:

<?php
    header("Refresh: 5; URL=$url1");
    include('filename.txt');
?>

Which refreshes the page every five seconds to see if the .txt file is modified. I dislike this method because it spams my logs of who is viewing the webpage with the same information.

I was wondering if I could modify the .php to refresh only filename.txt is modified.

  • 写回答

2条回答 默认 最新

  • dongyuandou2521 2016-03-31 09:28
    关注

    Use filetime() for this. http://php.net/manual/en/function.filemtime.php

    Example from there

    <?php
    // outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.
    
    $filename = 'somefile.txt';
    if (file_exists($filename)) {
        echo "$filename was last modified: " . date ("F d Y H:i:s.",  filemtime($filename));
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么