Why is CakePHP inserting a space before my xml layout?
Question
I am having a really frustrating problem in CakePHP where a space keeps coming up at the beginning of my KML file layout which causes Google Earth to reject the KML file!
<?php header("Content-disposition: attachment; filename=area.kml");
header("Content-Type: application/vnd.google-earth.kml+xml kml; charset=utf8");
header("Content-Transfer-Encoding: binary");
header("Pragma: no-cache");
header("Expires: 0");
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<?php echo $content_for_layout ?>
</Document>
</kml>
for the output I get
" <?xml version="1.0" encoding="UTF-8"?>"
ect ect please help!
Solution
This can happen if you're including a php file that has a space after the closing ?>
. For this reason, it is generally recommended that you don't include that tag (except, e.g., in a view, where you're echo
ing a variable and other content follows).
OTHER TIPS
It's the c/r after the ?> tag and before the <kml tag. Put them together and it should be better. Like this...
?><kml
use ob_clean ();
to clean the white space
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow