What is the potential issue with using the header() function in PHP, as seen in the provided code snippet?

The potential issue with using the header() function in PHP is that it must be called before any output is sent to the browser. If there is any whitespace or other output before the header() function call, it will result in a "Headers already sent" error. To solve this issue, you can ensure that there is no output before the header() function call by using output buffering.

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

// Your PHP code here

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

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