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>'; 

    2 answers 2

    Do not forget about the tag (which is located in the <head> )

     <meta http-equiv="refresh" content="5; url=http://example.com/"> 

    where 5 is the number of seconds through which the browser will make the transition to the address specified after url= .

    https://en.wikipedia.org/wiki/Meta_refresh

      The best would be a delayed output ob_start() , etc.

      http://vk-book.ru/redirekt-v-php-pri-uzhe-zadannyx-zagolovkax/