PHP/File Directory/touch
Версия от 10:37, 26 мая 2010; (обсуждение)
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");
?>