Currently I'm doing it like this:
$f = fopen('test', 'w');
fwrite($f, 'Hi');
fclose($f);
But I have a loop that does some expensive stuff (with files), and I'd like to avoid opening and closing the file handle every time I want to overwrite "test"
It should be something like this:
$f = fopen('test', 'w');
$i = 0;
while($ < 50000){
$i++;
foverwrite($f, 'i = ' . $i);
sleep(5); // just a example
}
fclose($f);
Is this possible?
This script runs in the background in CLI mode and I'm reading the test file from the web with ajax like every 2 seconds. Basically I'm trying to display a progress bar lol