touch()
创建于 2024-12-03 /
52
字体:
[默认]
[大]
[更大]
❮ PHP 文件系统参考手册
filename = "test.txt";
if (touch($filename)) {
echo $filename . " modification time has been changed to present time";
} else {
echo "Sorry, could not change modification time of " . $filename;
}
?>
❮ PHP 文件系统参考手册
实例
设置指定文件的访问和修改时间:
<?phpfilename = "test.txt";
if (touch($filename)) {
echo $filename . " modification time has been changed to present time";
} else {
echo "Sorry, could not change modification time of " . $filename;
}
?>
定义和用法
touch() 函数设置指定文件的访问和修改时间。
注释: 如果指定的文件不存在,则创建。
语法
touch(filename, time, atime)参数值
参数 | 描述 |
---|---|
filename | 必需。规定要接触的文件。 |
time | 可选。设置时间。默认是当前系统时间。 |
atime | 可选。设置访问时间。默认是当前系统时间。 |
说明
尝试将由 filename 给出的文件的访问和修改时间设定为指定的时间。如果没有设置可选参数 time,则使用当前系统时间。如果给出了第三个参数 atime,则指定文件的访问时间会被设为 atime 。
如果成功则返回 true,失败则返回 false。
提示和注释
注释:如果文件不存在,则会被创建。
技术细节
返回值: | 成功为 TRUE,失败为 FALSE |
---|---|
PHP 版本: | 4.0+ |
PHP 更新日志: | PHP 5.3 - |
❮ PHP 文件系统参考手册
0 人点赞过