PHP include() before doctype, causing a white space

前端 未结 5 1952
無奈伤痛
無奈伤痛 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:14

    OK, these steps should fix your problem:

    1. Go through all PHP files on your site. If the file ends with ?> (and possibly some whitespace), remove the ?>. (Of course, if there's some HTML text after the ?> then you shouldn't remove it.)

    2. While doing the above, also check that there's no whitespace in front of the first in any files.

    3. If you still have problems after that, check for invisible characters in front of the . There are several ways to do that, but looking at a hex dump of the files is one good way. The first two bytes of each PHP file (that doesn't begin with HTML text) should be (hex 3c 3f).

    In the unlikely event that those steps won't solve the problem, let us know (and preferably include a link to a page where the problem occurs, so that we can check the output ourselves).

提交回复
热议问题