What potential issue can arise when using header('Location: index.php') in PHP?

Using header('Location: index.php') can potentially cause a "headers already sent" error if there is any output sent to the browser before the header function is called. To solve this issue, make sure there is no whitespace or HTML content before the header function call. One way to prevent this error is to use output buffering to buffer the output before sending it to the browser.

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

// Your PHP code here

header('Location: index.php'); // Redirect to index.php

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