Jump to content

new to php, and this problem is blowing my mind


michaelreneer

Recommended Posts

Ok, here it is.

 

I have created a website with php. The pages generated by the php are standards compliant xml. As I navigate through my website everything is as should be, except for when randomly my styles go haywire. Now this phenomenon happens site-wide so not page specific and it happens at random intervals. Meaning that I can sit on the home page and hit refresh 30 times and a random 5 will be messed up. It happens in all the browsers that I have tested. It only happens when its online, when its on my local machine things are fine. After I generate a screwed up page I check the compatmode the browser and it yields that in fact the page was generated in backCompat or quirks mode. When the page displays as normal the browser shows the page was generated with css1compat or compatible.

 

My hypothesis is that the php is parsing inconsistently and occasionally extra hex characters are being inserted into the beginning of the html. What I have read is that sometimes if there are comments or characters in front of the <?xml ... start of the page then the browser kicks it over to quirks mode. On the other hand I also remember reading that this only occurred in ie6.

 

This problem only happens when the site is live and not when it is on my local machine, its intermittent, I am more then happy to give any more information just ask. I would love help.

 

 

Michael

Link to comment
Share on other sites

http://www.w3.org/QA/2002/04/valid-dtd-list.html

 

has

 

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 

<head>

<title>An XHTML 1.0 Strict standard template</title>

<meta http-equiv="content-type"

content="text/html;charset=utf-8" />

<meta http-equiv="Content-Style-Type" content="text/css" />

</head>

 

<body>

 

    <p>… Your HTML content here …</p>

 

</body>

</html>

 

 

is this not correct?

Link to comment
Share on other sites

Maybe this will help:

http://en.wikipedia.org/wiki/XHTML

 

XML Declaration

 

A character encoding may be specified at the beginning of an XHTML document in the XML declaration when the document is served using the application/xhtml+xml MIME type. (If an XML document lacks encoding specification, an XML parser assumes that the encoding is UTF-8 or UTF-16, unless the encoding has already been determined by a higher protocol.)

 

For example:

 

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

 

The declaration may be optionally omitted because it declares as its encoding the default encoding. However, if the document instead makes use of XML 1.1 or another character encoding, a declaration is necessary. Internet Explorer prior to version 7 enters quirks mode if it encounters an XML declaration in a document served as text/html.

Link to comment
Share on other sites

since removing the <?xml ... jazz i have not been able to duplicate the phenomenon. So I was encountering this issue because my files were probably saved as a different encoding then the xml parser of the browser?

 

can anyone give me an example of when you would want to use the optional

 

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

 

and when you would not want to ?

 

Thanks Michael

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.