Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
886 views
in Technique[技术] by (71.8m points)

html - Somehow php broke doctype

I created two threads here and here about that internet explorer works in quirks mode and that broke the layout. After a bit of investigation I found that somehow php make some mess.

For example If I run the code below as html page on web server IE parse it correctly.I`m using small CMS, so if I divide the code in three parts lets say header main footer (CMS combine them) then IE show quirks mode and the layout is broken. The html output from php file is the same as that below.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <style type="text/css" media="screen">
            body{
                font: 11px Tahoma, Verdana, Arial, sans-serif;
                color: #707070;
                background: #8c2727 url('../img/bgr_red.png') repeat-x;
            }

            a {
                color:#bc2828;
                text-decoration:none;
                font-weight: bold;
                outline: none;
            }


            #wrapper{
                position: relative;
                width: 960px;
                margin: 70px auto;
                background-color: #fff;
                border: 1px solid red;
            }

        </style>
    </head>

    <body>
    <div id="wrapper">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
    </body>
    </html>

I belive that the problem is in CMS. But what could broke the doctype ?

EDIT: Here is screenshot from Fiddler See the rectangle. What is that ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Most likely there is some output going to the browser before the doctype.

Ensure that:

  • There is no white space or any other kind of data before the <?php opening tags
  • There is no BOM at the beginning if your files are saved using some Unicode encoding

...in any of the files that are being parsed to generate your output.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...