PHP include causes white space at the top of the page

后端 未结 15 1109
無奈伤痛
無奈伤痛 2020-11-30 09:36

I have a problem on a site that I am making. There is this line of white space at the top of my page. I can not find out where it is coming from. It might be because of extr

相关标签:
15条回答
  • 2020-11-30 10:18

    I just downloaded Notepad++ and should advise UTF-8 without BOM is not an encoding option. Choose only "UTF-8" not the "UTF-8 BOM". That worked.

    0 讨论(0)
  • 2020-11-30 10:19

    Tested all suggestion online, solved with notepad, procedure :

    1. Copy all content of the file to include, from php without <?
    2. Open Notepad and type <? then paste all code
    3. Enjoy
    0 讨论(0)
  • 2020-11-30 10:20

    you can solve this problem doing the following...

    based in what scunliffe said... you can avoid this character... example

    $file = file_get_contents('header.php');
    $file = substr($file, 3, strlen($file));
    echo $file;
    

    so, you're skipping this bug...

    regards

    0 讨论(0)
  • 2020-11-30 10:20

    While reviewing your website output on firebug, i found small issue on top of html rendering. view in screen shot. firebug report

    It may be due to missing doctype on top of page. Add the following doctype on top of page and see output again.

    <!doctype html>
    <html itemtype="http://schema.org/WebPage" xmlns="http://www.w3.org/1999/xhtml"   xmlns:og='http://opengraphprotocol.org/schema/'
    xmlns:fb='http://www.facebook.com/2008/fbml'>
    
    0 讨论(0)
  • 2020-11-30 10:22

    In Notepad++ you can change the encoding of the file to "UTF-8 without BOM" from the "Encoding" menu. This fixes the problem for me.

    0 讨论(0)
  • 2020-11-30 10:22

    Try this this is the best idea that I know, cheers

    <div style="position:absolute;">
    <?php include("conn.php"); ?>
    </div>
    <!DOCTYPE html>
    
    0 讨论(0)
提交回复
热议问题