What potential issues can arise when using header() function with Location in PHP?

When using the header() function with Location in PHP, potential issues can arise if there is any output sent to the browser before the header is set. This can result in a "headers already sent" error. To solve this issue, make sure to call the header() function before any output is sent to the browser.

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

// Your PHP code here

header("Location: https://www.example.com");
exit();

ob_end_flush(); // Flush the output buffer
?>