View Single Post
  #41 (permalink)  
Old 04-18-2008, 07:11 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Filesystem Object in PHP

flock() example
PHP Code:
<?php

$fp 
fopen("/tmp/lock.txt""w+");

if (
flock($fpLOCK_EX)) { // do an exclusive lock
    
fwrite($fp"Write something here\n");
    
flock($fpLOCK_UN); // release the lock
} else {
    echo 
"Couldn't lock the file !";
}

fclose($fp);

?>
flock() requires a file pointer, you may have to use a special lock file to protect access to a file that you intend to truncate by opening it in write mode (with a "w" or "w+" argument to fopen()).
__________________
With,
J. Jeyaseelan

Everything Possible
Reply With Quote
Sponsored Links