PHP/File Directory/touch
Changing file modification times
<?php
touch("shemp.php"); // set modification time to now
touch("joe.php",$timestamp); // set modification time to $timestamp
?>
Error-prone file locking
<?
$locked = 0;
while (! $locked) {
if (! file_exists("guestbook.txt.lock")) {
touch("guestbook.txt.lock");
$locked = 1;
} else {
sleep(1);
}
}
?>
If a file does not yet exist, you can create one with the touch() function.
<?
touch("myfile.txt");
?>