Re: File locking in PHP???

From: Date: Thu, 15 Jul 2004 22:00:09 +0000
Subject: Re: File locking in PHP???
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-190639@lists.php.net to get a copy of this message
* Thus wrote Scott Fletcher: > Nah! I'll settle for a simplier one... file_exists() by checking to see > if the file exist then spit out the error message. Meaning the file is in > use... Don't use file_exists() for that, it will fail miserable with racing conditions. a better more portable way would be to use mkdir(): if (mkdir('mylockdir', 0755) ) { // we've obtained a lock // do stuff // and unlock it rmdir('mylockdir'); } else { // unable to obtain lock } Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid!

« previous php.general (#190639) next »