PHP include() before doctype, causing a white space

前端 未结 5 2041
無奈伤痛
無奈伤痛 2021-01-20 13:37

I have a website with a white space problem. I am including a few files before the doctype and this is causing a white space to be outputted.

After searching I have

5条回答
  •  死守一世寂寞
    2021-01-20 14:29

    You may be able to fix the problem like this:

    
    

    But I have observed buggy behaviour in this respect (although not since PHP4), so the easiest solution that guarantees a fix is to put the before the include - since neither included file outputs anything, and would break your document if it did.

    
    
    
    

    Or this:

    \n";
    
      include ("include/session.php");
      include ("include/updatestage.php");
    
    ?>
    
    

    Remember to make sure that the < in the opening tag is the first character in all files if you go with the second option.

    EDIT Having in the first place completely failed to take into account the session/cookies problem that has reared it's ugly head, here is a working solution:

    \n";
    
      include ("include/session.php");
      include ("include/updatestage.php");
    
      ob_end_flush();
    
    ?>
    
    

提交回复
热议问题