Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

touch()

Example

Updates the access and modification times 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;
}
?>

Definition and Usage

The touch() function updates the access and modification times of the specified file.

 

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

Syntax

touch(filenametimeatime)

Parameter Values

Parameter

Description

filename

Required. Specifies the file to update.

time

Optional. Specifies the time to set for the file; the current system time is used by default.

atime

Optional. Specifies the access time; by default, it uses the current system time if no parameter is set, or the same value as the time parameter if it is provided.

Technical Details

Return Value:

Returns TRUE on success, FALSE on failure.

PHP Version:

4.0+

PHP Changelog:

PHP 5.3 –