Re: file_set_contents() do several times?

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

 



David Otton napsal(a):
> 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.
>


I am not appending anything, just ensuring that it will be written (and giving it max. 3 tryes).


=== Martin Scotta replied:

In my experience file_put_contents never fails, except about file permissions, but this is not the case.

---

Thanks for your replies.

Martin

--
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