As you know, the header function should only be used before the page content has been generated. And what if you need after? Is there anything better mix in javascript type
echo '<script language="JavaScript"> window.location.href = "index.php"</script>';