Aaron Yodaiken
Aaron Yodaiken

Reputation: 19551

how to get file contents of locked file in PHP

What's the best way, idiomatically, of getting the file contents (into a string) of a flock'd file in PHP?

Edit: To be clear, this is something locked by the current page/process. Something like:

if(flock($fp ...)) {
  $str = READFILECONTENTS($fp);
  flock(...);
}

Upvotes: 1

Views: 1299

Answers (1)

Alix Axel
Alix Axel

Reputation: 154553

Don't. Wait for the lock to be released and only then read it.

Or just read it anyway.

Upvotes: 1

Related Questions