How to fix “Headers already sent” error in PHP

This question already has an answer here:

  • How to fix “Headers already sent” error in PHP 11 answers

  • This type of problem is caused when you use header after you write in your page. I assume you code might look like ::

     <html>
       <head>
         <title> title </title>
         .........
       </head>
    
       <body>
        .....
         <?php 
            header() // checking some header
         ?>
         .....
       </body>
     </html>
    

    If so, use header() before html or any kind of echo or writing code. But this is not correct solutions. You can use ob_start . This is the best solution. check this

    链接地址: http://www.djcxy.com/p/34694.html

    上一篇: 标题已由Error发送

    下一篇: 如何解决PHP中的“Headers already sent”错误