I have the script is which runned by Cron jobs. So, while it runs, I can't see what output of the task is. (errors and so on.)
So I need to write browser output to log file using PHP. How can I do this ?
You can use output buffers to write browser output to a log file,
Example:
<?php
ob_start();
echo 'Lorem ipsum dolor sit amet consectetur adipiscing elit';
echo 'Cras in dolor fringilla est fermentum porttito';
echo 'bla bla bla...';
echo 'bla bla bla...';
file_put_contents('/path/to/log.txt',ob_get_contents());
ob_end_flush();
?>
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