Re: file_set_contents() do several times?

From: Date: Mon, 20 Jul 2009 08:16:15 +0000
Subject: Re: file_set_contents() do several times?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-295600@lists.php.net to get a copy of this message
2009/7/20 Martin Zvarík <mzvarik@gmail.com>: > > <?php > $i = 0; > do { >   $i++; >   $r = file_put_contents('file.txt', 'content'); > } while($r === false && $i < 3); > > if ($r === false) die('error'); > > ?> > > Makes sense? or is it enough to do it just once? Assuming 'content' changes, and this is the cut-down example... $r = file_put_contents('file.txt', 'content', FILE_APPEND); There's a small overhead in opening/closing the file three times instead of one, but I doubt that's going to be an issue for you.

« previous php.general (#295600) next »