What is the common error message encountered when using the header function in PHP?
When using the header function in PHP, a common error message encountered is "Cannot modify header information - headers already sent". This error occurs when there is output (such as HTML, whitespace, or error messages) sent to the browser before the header function is called. To solve this issue, make sure to call the header function before any output is sent to the browser, or use output buffering to capture any output before sending headers.
<?php
ob_start(); // Start output buffering
// Your PHP code here
header("Location: https://www.example.com"); // Redirect using the header function
ob_end_flush(); // Flush output buffer and send headers
?>