PHP include causes white space at the top of the page

后端 未结 15 1170
無奈伤痛
無奈伤痛 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:27

    This problem has also bothered me for a long time, until I found a very simple solution.

    This problem is caused by a BOM character, which is used to tell code page and which endian is of a text file. When you include a PHP file, this character will be included as well. Although you will not see the BOM character, but it might cause gap on your page.

    My solution is here. You don't have to remove this character from files. What you have to do is like this:

    
    

    Using HTML comment mark to wrap php code which includes other php files. And the BOM character will be considered as comment and will not appear on page.

提交回复
热议问题