I have a script which constanly append strings into a file.
For example (this is a test script):
$i = 1;
$file = 'wikipedia/test.txt';
$text = 'the quick brown fox jumps over the lazy dog';
while($i!=0)
{
file_put_contents($file, $text, FILE_APPEND );
}
But for an unknown reason my program stops appending strings when the text file reached the file size of 2097156 B . It wasn't a disk space issue since i could still create another text file yet limited to the same exact file size value.
I tried using other php functions fwrite, fputs but still didn't work out.
An开发者_运维问答y idea why this problem occurs?
Seems unlikely, but you might have run up against PHP's max_execution_time
if its current setting is very low. Try increasing its value in php.ini
Your loop doesnt make sense. It never changes $i. Try it without the while.
$file = 'wikipedia/test.txt';
$text = 'the quick brown fox jumps over the lazy dog';
file_put_contents($file, $text, FILE_APPEND );
There are several issues that could cause this problem.
- You may have encountered the max execution time limit ( default: 30 seconds ).
- You may have exhausted the memory limit ( default: varies by version)
- Something may have changed on disk ( the file permissions may have changed, or you may have exceeded a disk quota).
PHP's error output would be invaluable for identify which of these issues may have contributed to the problem.
精彩评论