(PHP 4, PHP 5, PHP 7)
touch — 锟借定锟侥硷拷锟侥凤拷锟绞猴拷锟睫革拷时锟斤拷
$filename
[, int $time
= time()
[, int $atime
]] ) : bool
锟斤拷锟皆斤拷锟斤拷 filename
锟斤拷锟斤拷锟斤拷锟侥硷拷锟侥凤拷锟绞猴拷锟睫革拷时锟斤拷锟借定为锟斤拷锟斤拷锟斤拷 time
锟斤拷
注锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷腔岜伙拷薷牡模锟斤拷锟斤拷锟斤拷屑锟斤拷锟斤拷锟斤拷锟斤拷锟�
锟斤拷锟斤拷募锟斤拷锟斤拷锟斤拷冢锟斤拷锟结被锟斤拷锟斤拷锟斤拷
filename
要锟借定锟斤拷锟侥硷拷锟斤拷锟斤拷
time
要锟借定锟斤拷时锟戒。锟斤拷锟矫伙拷锟斤拷峁╋拷锟斤拷锟� time
锟斤拷锟绞癸拷玫锟角跋低筹拷锟绞憋拷洹�
atime
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷募锟斤拷姆锟斤拷锟绞憋拷锟结被锟斤拷为
atime
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� 为time
锟斤拷锟斤拷锟矫伙拷懈锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞癸拷玫锟角跋低呈憋拷洹�
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
锟芥本 | 说锟斤拷 |
---|---|
5.3.0 | 锟杰癸拷锟睫革拷 Windows 锟斤拷目录锟斤拷锟斤拷锟斤拷薷锟绞憋拷洹� |
Example #1 touch() 锟斤拷锟斤拷
<?php
if (touch($filename)) {
echo $filename . ' modification time has been changed to present time';
} else {
echo 'Sorry, could not change modification time of ' . $filename;
}
?>
Example #2 使锟斤拷 time
锟斤拷锟斤拷锟斤拷 touch()
<?php
// This is the touch time, we'll set it to one hour in the past.
$time = time() - 3600;
// Touch the file
if (!touch('some_file.txt', $time)) {
echo 'Whoops, something went wrong...';
} else {
echo 'Touched file with success';
}
?>
Note:
注锟解:锟斤拷同锟侥硷拷系统锟斤拷时锟斤拷锟斤拷卸戏锟斤拷锟斤拷锟斤拷锟斤拷遣锟斤拷锟酵拷摹锟�
锟斤拷 PHP 5.3.0 之前锟睫凤拷锟睫革拷 Windows 锟斤拷目录锟斤拷锟斤拷锟斤拷薷锟绞憋拷洹�