How can the issue of "Cannot modify header information" be resolved when trying to redirect in PHP?

When encountering the "Cannot modify header information" issue in PHP, it is typically due to attempting to modify headers after they have already been sent to the browser. To resolve this, make sure that there is no output (such as HTML, whitespace, or error messages) before using functions like header() to redirect the user.

ob_start();
header('Location: new_page.php');
exit();