...

View Full Version : Line Breaks appearing...



gsnedders
10-11-2004, 09:15 PM
I have the following code:
<?php
$mime = "text/html";
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
if(preg_match("/application\/xhtml\+xml;q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
$xhtml_q = $matches[1];
if(preg_match("/text\/html;q=q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
$html_q = $matches[1];
if((float)$xhtml_q >= (float)$html_q) {
$mime = "application/xhtml+xml";
}
}
} else {
$mime = "application/xhtml+xml";
}
}
header ("Content-type: $mime");
require 'giztimer.inc.php';
$t1 = new Giz_Timer();
If ($mime == "application/xhtml+xml") {
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Firefox receives this as:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
and throws up a XML parsing error: XML Parsing Error: xml processing instruction not at start of external entity... So, the question is, how do I remove the blank line before the XML declaration...

liorean
10-11-2004, 09:47 PM
Strangely, I can remember seeing this same problem on a blog some time ago. Can't remember the resolution, though.

Anyway, this is a PHP problem and not a HTML problem, so moving over to the server side guys.

gsnedders
10-12-2004, 12:33 AM
Anyway, this is a PHP problem and not a HTML problem, so moving over to the server side guys.It wouldn't be an HTML problem anyway, it would've been a XHTML problem ;)

Why I posted it there? I couldn't make my mind up of whether it was a XHTML or PHP problem...

AaronW
10-12-2004, 01:03 AM
I'm going to guess it's this line:

require 'giztimer.inc.php';

Because the very nature of require is to replace itself with content. Since your .inc.php file is probably void of output, require replaces itself with nothing (so a blank line is left).

gsnedders
10-12-2004, 01:08 AM
Thanks...

AaronW
10-12-2004, 01:20 AM
Why the ellipsis points? Was I wrong? :confused:

gsnedders
10-12-2004, 01:22 AM
Why the ellipsis points? Was I wrong? :confused:Because I'm too lazy to write Thank you so much...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum