What best practices should PHP developers follow to prevent issues with headers being sent prematurely in their scripts, especially when dealing with server migrations?
When dealing with server migrations, PHP developers should ensure that no output is sent to the browser before setting headers using functions like `header()` or `setcookie()`. To prevent issues with headers being sent prematurely, developers can use output buffering to capture any output before sending headers. This can be achieved by using `ob_start()` at the beginning of the script and `ob_end_flush()` at the end to send the buffered output.
<?php
ob_start();
// Your PHP code here
ob_end_flush();