Forum Moderators: coopster
<?xml version="1.0" encoding="iso-8859-1"?>
<!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">
Once I remove the top tag and just have <head> without the xmlns attribute, it works fine. I don't really care whether I have the DTD normal or not but why does this interfere with the display of a PHP page? Is it because of the "<?"
Once I do that, the page displays with no stylesheet, even though it's in my head tag and would otherwise work fine in HTML. Please help me, I'm totally lost
An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol.
-- from [w3.org...]
Historically, the character encoding of an HTML document is either specified by a web server via the charset parameter of the HTTP Content-Type header, or via a meta element in the document itself. In an XML document, the character encoding of the document is specified on the XML declaration (e.g., <?xml version="1.0" encoding="EUC-JP"?>).
-- [w3.org...]
Because XHTML 1.0 is based on XML, it is common to add an XML declaration at the beginning of the markup, even if it is served as HTML.
--http://www.w3.org/International/articles/serving-xhtml/#declaration
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<link rel="stylesheet" type="text/css" href="../contact.css" media="all" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
Like I mentioned, this would work fine in HTML, even without putting it on the server, Frontpage shows it without any CSS applied to it. The only PHP on the page is a contact form.
Your issue is with the PHP short_open_tag [php.net]. Turn it off or echo the declaration as jatar_k mentioned and you'll be off and running.
PHP Basic syntax [php.net] and the rest of the tutorial will be an enlightening read -- go get 'em.