Page 1 of 1

file_put_contents() and locking mechanism

Posted: Thu May 17, 2007 12:39 pm
by ngungo
Do file_put_contents() and file_get_contents() have locking mechanism built-in?

Posted: Thu May 17, 2007 1:26 pm
by Christopher
According to the documentation (which you have no doubt read thoroughly):

http://www.php.net/manual/en/function.f ... ntents.php

There is a flag named LOCK_EX which appears to do file locking. However that flag was added in 5.1.0 so you would need a current version of PHP5 to use it. Otherwise you would need to do fopen() and then locking.

Posted: Thu May 17, 2007 1:57 pm
by ngungo
arborint wrote:According to the documentation (which you have no doubt read thoroughly):
Thanks! I did read once then somehow I don't recall that file locking option. I should read it again before asking here. Thanks again.