PHP中的touch()函数
该touch()方法设置文件的访问和修改时间。成功返回TRUE,失败返回FALSE。
语法
touch(filename, time, atime)
参数
filename-设置文件名。
时间-设置时间。默认为当前系统时间。
atime-设置访问时间。默认为当前系统时间。
返回
如果touch()成功,该函数将返回TRUE,否则将返回FALSE。
示例
<?php
$myfile = "new.txt";
//将修改时间更改为当前系统时间
if (touch($myfile)) {
echo ("The modification time of $myfile set to current time.");
} else {
echo ("The modification time of $myfile can’t be updated.");
}
?>输出结果
The modification time of new.txt set to current time.
让我们来看另一个例子。
示例
<?php
$myfile = "new.txt";
$set_time = time() - 28800;
//更改修改时间
if (touch($myfile, $set_time)) {
echo ("The modification time of $myfile updated to 8 hrs in the past.");
} else {
echo ("The modification time of $myfile can’t be updated.");
}
?>输出结果
The modification time of new.txt updated to 8 hrs in the past.
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西