php vs htm, weird gaps

2019-08-21 09:19发布

the normal one:

http://labvc.x10hosting.com/AT/site/home.htm

VS

the odd one:

http://labvc.x10hosting.com/AT/site/home.php

when i look at the code side by side, its almost identical, the only thing that would make them give that weird gap should be the CSS but they're using the same sheet.

ideas?


EDIT: I checked and made minute changes to the code, look again at the source.
Both are EXACTLY the same. wtf is with this gap.


EDIT: there's a pixel wide character just before the xml deceleration, how do i stop it form occurring?

标签: php css xhtml
5条回答
Animai°情兽
2楼-- · 2019-08-21 09:49

The php page generates a "." before the doctype which explain the extra space

the html page

<!DOCTYPE html

    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

the php page

.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

delete any code above the doctype in the php page

查看更多
疯言疯语
3楼-- · 2019-08-21 09:55

You have an extra bit of white space at the top of the PHP file's source code (before the xml declaration).

查看更多
何必那么认真
4楼-- · 2019-08-21 09:57

There's a on the php one at the top of the page explaining the gap IMHO

查看更多
萌系小妹纸
5楼-- · 2019-08-21 09:59

Your PHP output has a double byte-order-mark at the head.

Inspecting your code with Firebug, I see this as the first line

<?xml version="1.0" encoding="UTF-8"?>

Now, all those funky characters there are just ISO-8859-1 decodings of the UTF-8 BOM (0xEF 0xBB 0xBF).

These are possibly added by your IDE/editor into the head of the PHP files themselves. Check your preferences and see what encoding is being used. If it's something like "UTF-8 + BOM" then switch it to just "UTF-8" and that should fix it.

查看更多
甜甜的少女心
6楼-- · 2019-08-21 10:03

If you're including any files at the top of the PHP file it could be that you actually have whitespace or a period AFTER the ending ?> in the included file

header.php
<?php
  phpstuff...
?> <whitespace or period here>

home.php
<?php
  include "header.php";
?>

This can be solved by never using ?> in pure PHP files. It's ok to leave it open like this:

<?php
  phpstuff...
查看更多
登录 后发表回答