file_put_contents() and locking mechanism

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ngungo
Forum Commoner
Posts: 75
Joined: Thu Jun 08, 2006 10:45 pm

file_put_contents() and locking mechanism

Post by ngungo »

Do file_put_contents() and file_get_contents() have locking mechanism built-in?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
ngungo
Forum Commoner
Posts: 75
Joined: Thu Jun 08, 2006 10:45 pm

Post 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.
Post Reply