PHP touch() Function

Definition and Usage

The touch() function sets the access and modification time of the specified file.

Syntax

touch(filename,time,atime)
Parameters Description
filename Required. Specifies the file to be accessed.
time Optional. Set the time. The default is the current system time.
atime Optional. Set the access time. The default is the current system time.

Description

Attempts to set the access time of the file specified by filename the access and modification time of the specified file will be set to the specified time. If no optional parameters are set time, then the current system time will be used. If the third parameter is given atime, then the access time of the specified file will be set to atime.

Returns true if successful, false otherwise.

Tips and Comments

Note:If the file does not exist, it will be created.

Example

<?php
touch("test.txt");
?>