Re: file_set_contents() do several times?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/7/20 Martin Zvarík <mzvarik@xxxxxxxxx>:
>
> <?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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux