开发者

php vs htm, weird gaps

开发者 https://www.devze.com 2022-12-14 04:15 出处:网络
the normal one: http://labvc.x10hosting.com/AT/site/home.htm VS the odd one: http://labvc.x10hosting.com/AT/site/home.php

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 weir开发者_运维技巧d 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?


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


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.


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


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...


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

0

精彩评论

暂无评论...
验证码 换一张
取 消