php文件时间函数fileatime filemtime filectime区别实例讲解
时间:2016-08-19
php fileatime、filemtime、filectime三个函数都是用来获取文件时间的,但是三者之间是有区别的,fileatime用于取得文件的上次访问时间,filemtime函数用于取得文件上传修改时间,filectime用于取得文件的 inode 修改时间(文件创建时间),本文章向大家实例介绍三者的区别。
fileatime
fileatime返回文件上次被访问的时间, 或者在失败时返回 FALSE 。时间以 Unix 时间戳的方式返回。
实例:
<?php
$file = "test.txt";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
if ( ! file_exists( $f ) ){
print "$f does not exist<BR>";
return;
}
print "$f was accessed on ".date( "D d M Y g:i A", fileatime( $f ) )."<br>";
}
?>
filemtime
filemtime函数返回文件中的数据块上次被写入的时间,也就是说,文件的内容上次被修改的时间。
实例:
<?php
$file = "test.txt";
outputFileTestInfo( $file );
/* http://www.manongjc.com/article/1374.html */
function outputFileTestInfo( $f ){
if ( ! file_exists( $f ) ){
print "$f does not exist<BR>";
return;
}
print "$f was modified on ".date( "D d M Y g:i A", filemtime( $f ) )."<br>";
}
?>
filectime
filectime返回文件上次 inode 被修改的时间,即文件创建时间, 或者在失败时返回 FALSE 。 时间以 Unix 时间戳的方式返回。
<?php
$file = "test.txt";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
if ( ! file_exists( $f ) ){
print "$f does not exist<BR>";
return;
}
print "$f was changed on ".date( "D d M Y g:i A", filectime( $f ) )."<br>";
}
?>
- PHP小知识
- Where's Waldorf?
- POj 1797 Heavy Transportation
- 卡特兰数简介原理性质应用参考:
- UVA Machined Surfaces
- NBUT 1117 Kotiya's Incantation
- React第三方组件1(路由管理之Router的使用④按需加载-上)
- React第三方组件1(路由管理之Router的使用③传参)
- Kindergarten Counting Game
- React第三方组件1(路由管理之Router的使用②多层级跳转及重定向)
- 括号配对问题描述输入输出样例输入样例输出解析代码实现运行结果参考链接
- React第三方组件1(路由管理之Router的使用①简单使用)
- POj 2253 Frogger
- React项目配置7(ES7的Async/Await的使用)
- php概述
- php教程
- php环境搭建
- PHP书写格式
- php变量
- php常量
- PHP注释
- php数组
- php字符串 string
- PHP整型 integer
- PHP浮点型 float
- php布尔型
- php数据类型之数组
- php数据类型之对象
- php数据类型之null
- php数据类型之间的转换
- php运算符
- php表达式
- PHP循环控制
- PHP流程控制
- php函数
- php全局变量
- PHP魔术变量
- php命名空间
- php 日期
- PHP包含文件
- php文件
- PHP 文件上传
- php Cookies
- php Sessions
- php email
- php安全email
- php错误处理
- PHP异常处理
- php过滤器
- PHP 高级过滤器
- php json
- php 表单
- PHP MySQL 简介
- PHP 连接 MySQL
- php创建数据库
- php 创建表
- php mysq 插入数据
- PHP MySQL 插入多条数据
- PHP MySQL 预处理语句
- php mysql 读取数据
- php mysql where
- PHP MySQL Order By
- PHP MySQL Update
- PHP MySQL Delete
- php ODBC