Jump to content

[SOLVED] mysterious whitespace


Guardian-Mage

Recommended Posts

I am using php to create dynamic websites. I have never had this problem. PHP is outputting one whitespace character in my source code before everything else which causes an error is firefox.

 

<?php
include("generate.php");
$gen = new generate;
$gen->makeHead("about");
?>

If I put an echo statement before the include, the whitespace isn't there. If I put it after it is there. Something in that PHP file is doing it.

 

<?php
#-------------------------------------------
# (C) 2008 DM Motorsports
# Dynamic Content Generator
#-------------------------------------------	

class generate {
function makeNav($page) {
	echo "<div id=\"nav\">";
	echo "<a href=\"index.html\">Home</a><br />\n";
	echo "<a href=\"\">About Us</a><br />";
	echo "<a href=\"\">Achievements</a><br />";
	echo "<a href=\"\">Schedule</a><br />";
	echo "<a href=\"\">Race Reports</a><br />";
	echo "<a href=\"\">Pictures</a><br />";
	echo "<a href=\"\">Movies</a><br />";
	echo "<a href=\"\">Sponsors</a><br />";
	echo "<a href=\"\">Classifieds</a>";
	echo "</div>";
}

function makeHead($id) {
	/*require_once("mime.php");
	$conneg=new contentNegotiation();
	$uastring=$_SERVER["HTTP_USER_AGENT"];
	header("Vary: Accept, User-Agent");
	if($conneg->compareQ("application/xhtml+xml,text/html")=="application/xhtml+xml"&&!strpos($uastring,"MSIE")){
		header("Content-Type:application/xhtml+xml");
		echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
		$flash=true;
	} else {
		header("Content-Type:text/html;charset=utf-8");
	}*/
	echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">";
	echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">";
	echo "<head>";
	echo "<meta http-equiv=\"Content-Type\" content=\"text/html; utf-8\" />";
	echo "<meta http-equiv=\"Content-Language\" content=\"en-us\" />";
	echo "<title>DM Motor Sports| #66</title>";
	echo "<meta http-equiv=\"Content-Language\" content=\"en-us\" />";
	echo "<meta name=\"Author\" content=\"Brandon Wamboldt/Northern Lights Technology\" />";
	echo "<meta name=\"Title\" content=\"DM Motor Sports| #66\" />";
	echo "<meta name=\"Description\" content=\"Daryl Mahar Motor Sports, the #66 Car. Come read our race reports and meet our team.\" />";
	echo "<meta name=\"Keywords\" content=\"racing, Daryl, Mahar, #66, Cars\" />";
	echo "<meta name=\"Robots\" content=\"index,follow\" />";
	echo "<meta name=\"last-modified\" content=\"2007/07/20\" />";
	echo "<meta name=\"revisit-after\" content=\"5_days\" />";
	echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\" />";
	echo "<script type=\"text/javascript\" src=\"swfobject.js\"></script>";
	echo "</head>";
	echo "<body id=\"$id\">";
}

function makeTopNav() {
	echo "<div id=\"head\">";
	echo "<div class=\"left\">Powered by <a href=\"http://northernlightstech.com/fusion\">Fusion Technology</a></div>";
	echo "<div class=\"right\"><a href=\"index.html\">Home</a> | <a href=\"about.html\">About Us</a> | <a href=\"contact.html\">Contact Us</a>";
	echo "</div>";
	echo "</div>";
}
}      
?> 

 

My page output is like this:

<?xml version=\"1.0\" encoding=\"utf-8\"?>
^
+--------------------Whitespace

Link to comment
https://forums.phpfreaks.com/topic/100042-solved-mysterious-whitespace/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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