I am having trouble with an update script. It runs for a few hours so I would like it to output live to a text file.
I start the document with
ob_start();
Then within the while loop (as it iterates through the records of the database) I have this
$size=ob_get_length();
if ($size > 0)
{
$content = ob_get_contents();
logit($contents);
ob_clean();
}
And finally the logit function
function logit($data)
{
file_put_contents('log.txt', $data, FILE_APPEND);
}
However the log file remains empty. What am I doing wrong?
Output Buffering is a method to tell the PHP engine to hold the output data before sending it to the browser.
The flush() function requests the server to send its currently buffered output to the browser. The server configuration may not always allow this to happen.
It's possible to turn on/off and change buffer size by changing the value of the output_buffering directive. Just find it in php. ini , change it to the setting of your choice, and restart the Web server.
try
logit($content);
// ^^ Note the missing s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With