filemtime_关于PHP Filemtime()函数

filemtime

If your website contains time-sensitive information—or even if it doesn't—you may want to display the last time a file was modified on the website. This gives users an accurate idea of how up to date the information on a page is. You can automatically draw this information from the file itself using the ​filemtime() PHP function.

如果您的网站包含时间敏感信息(即使没有),则可能要显示该网站上次修改文件的时间。 这使用户可以准确了解页面上的信息是最新的。 您可以自动绘制从使用filemtime()文件本身这些信息PHP函数

The filemtime() PHP function retrieves the Unix timestamp from the file. The date function converts the Unix timestamp time. This timestamp indicates when the file was last changed.

filemtime()PHP函数从文件中检索Unix时间戳。 date函数转换Unix时间戳时间。 此时间戳指示文件的最后更改时间。

显示文件修改日期的示例代码 ( Example Code to Display File Modification Date  )

When you use this code, replace "myfile.txt" with the actual name of the file you are dating.​

使用此代码时,请使用要约会的文件的实际名称替换``myfile.txt''。

<?php // outputs myfile.txt was last modified: December 29 2002 22:16:23. $filename = 'myfile.txt'; if (file_exists($filename)) {  echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename)); } ?>
<?php //输出myfile.txt的最新修改时间:2002年12月29日22:16:23。 $ filename ='myfile.txt'; 如果(file_exists($ filename)){回显“ $ filename上次修改:”。 日期(“ F d YH:i:s。”,filemtime($ filename)); }?>

Filemtime()函数的其他用途 ( Other Uses for Filemtime() Function )

In addition to time-stamping web articles, the filemtime() function can be used to select all articles older than a specified time for the purpose of deleting all old articles. It can also be used to sort articles by age for other purposes.

除了带有时间戳记的Web文章之外,filemtime()函数还可用于选择所有早于指定时间的文章,以删除所有旧文章。 它也可以用于按年龄对商品进行排序,以用于其他目的。

The function can come in handy when dealing with browser caching. You can force the download of a revised version of a stylesheet or page using the filemtime() function.

该功能在处理浏览器缓存时会派上用场。 您可以使用filemtime()函数强制下载样式表或页面的修订版。

Filemtime can be used to capture the modification time of an image or other file on a remote site.

Filemtime可用于捕获远程站点上映像或其他文件的修改时间。

关于Filemtime()函数的信息 ( Information on Filemtime() Function )

  • The results of the filemtime() function are cached. The clearstatcache() function clears the cache.

    filemtime()函数的结果被缓存。 clearstatcache()函数清除缓存。
  • If the filemtime () function fails, the code returns "false."

    如果filemtime()函数失败,则代码返回“ false”。

翻译自: https://www.thoughtco.com/automatically-display-when-file-last-modified-2693936

filemtime

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值