touch() 함수는 파일의 접근 및 수정 시간을 설정합니다. 성공하면 TRUE를, 실패하면 FALSE를 반환합니다.
구문
touch(filename, time, atime)
매개변수
-
파일 이름 - 파일명을 설정합니다.
-
시간 - 시간을 설정합니다. 기본값은 현재 시스템 시간입니다.
-
시간 - 액세스 시간을 설정합니다. 기본값은 현재 시스템 시간입니다.
반환
touch() 함수는 성공하면 TRUE를, 실패하면 FALSE를 반환합니다.
예시
<?php
$myfile = "new.txt";
// changing the modification time to current system time
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;
// changing the modification time
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.