PHP touch() function

Definition and Usage

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

Syntax

touch(filename,time,atime)
Parameters Description
filename Required. Specify 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

Attempt to set filename the access and modification time of the specified file is set to the specified time. If no optional parameters are set time, then use the current system time. 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");
?>