PHP touch() Function

PHP umask() Function
PHP tmpfile() Function

In this article, you will learn how to set the access and update time of a file in PHP. The touch() function in PHP sets the access and modification time of the specified file. The file is created if not exist.

what is the syntax of the TOUCH function in php?

touch(filename, time, atime)
ParameterDescription
filenameRequired. Specifies the file to touch
timeOptional. Sets the touch time. The current system time is set by default
atimeOptional. Sets the access time. Default is the current system time if no parameters are set, or the same as the time parameter if that parameter is set
PHP touch() method

examples of the TOUCH function

Example 1. In this example, we set the access and modification time of the specified file.

<?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 umask() Function
PHP tmpfile() Function
en English
X
Scroll to Top