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