How can output buffering be used to avoid header modification errors in PHP scripts?
Output buffering can be used to avoid header modification errors in PHP scripts by capturing the output before any headers are sent to the browser. This allows you to modify headers or send cookies without encountering errors. To implement this, you can use the ob_start() function at the beginning of your script to turn on output buffering, make any necessary header modifications, and then use ob_end_flush() to send the buffered output to the browser.
<?php
ob_start();
// Modify headers or send cookies here
ob_end_flush();
?>