在网站的管理系统中,有时需要查看某个文件是否被修改过、在什么时间被修改的、最后的修改时间是什么时候,本实例就可以实现这个功能,对表单中提交的文件进行判断,检测出修改时间。
关键技术
本实例主要应用filectime()和filemtime()函数,检测文件的incode最后改变时间和最后的修改时间,并应用date()函数对检测返回的时间戳进行格式化。
filectime()函数,返回指定文件filename的inode最后改变时间,语法如下:
int filectime(string filename);
成功则返回UNIX时间戳,否则返回FALSE。
filemtime()函数,返回指定文件filename的最后修改时间,语法如下:
成功则返回UNIX时间戳,否则返回FALSE。
设计过程
首先,设计网页页面。然后,创建一个表单,通过文件域提交要判断的文件。接着,获取表单中提交的文件路径,应用filectime()和filemtime()函数对提交的文件进行检测。最后,输出检测结果。
index.php文件的关键代码如下:
代码如下 | 复制代码 |
|
秘笈心法
获取文件的最后访问时间。
通过文件系统函数不但可以获取文件的最后修改时间,而且可以获取文件的最后访问时间,其应用的是fileatime()函数

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools