touch

bool touch(string filepath, [int timestamp]) 

Touches a file.

Returns:

TRUE on success; FALSE on error

Description:

Sets the timestamp on a file to the specified UNIX timestamp. If the timestamp is not specified, the current timestamp is used. If the file doesn’t exist, a zero-byte file is created.

Example:

Touch a file
<?php 
$file = "test_file"; 
touch ($file) 
  or die ("File '$file' says \"Don't touch me! Creep...\""); 
?> 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.