What best practices should be followed when constructing strings for header() in PHP to avoid errors or issues?

When constructing strings for the `header()` function in PHP, it's important to ensure that there are no output sent to the browser before calling `header()`. This is because headers must be sent before any actual output. To avoid errors or issues, make sure to use output buffering or place the `header()` function at the very beginning of the script.

<?php
ob_start(); // Start output buffering

// Your code here

header('Location: https://www.example.com'); // Send header before any output

ob_end_flush(); // Flush output buffer
?>