php touch 方法,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.

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值