Error-prone file locking : touch « File Directory « PHP






Error-prone file locking

 
<?
$locked = 0;
while (! $locked) {
    if (! file_exists('guestbook.txt.lock')) {
        touch('guestbook.txt.lock');
        $locked = 1;
    } else {
        sleep(1);
    }
}
?>
  
  








Related examples in the same category

1.Changing file modification times
2.If a file does not yet exist, you can create one with the touch() function.