Idontwantspam Posted May 1, 2007 Share Posted May 1, 2007 I have just started using PHP. I have always for my HTML used doctypes, XHTML 1.0 usually. Now that I'm using php, I have a question. When I put a doctype at the top of the php doc, the page doesn't appear. But when I remove it, everything's fine. Is there such thing as a doctype? Because I fail validation if I don't have a doctype. Is the solution to use <?phpecho "put the doctype here";?>at the top of the page so that when the browser (or validator) sees the page it sees the doctype? I'm not sure what to do here! Please help. Thanks. Link to comment Share on other sites More sharing options...
phkninja Posted May 1, 2007 Share Posted May 1, 2007 give us an example of code that doesnt work.in php you must have <?php before any code otherwise it wont recognise it as php information. Also are you creating a page dynaically using the php?e.g. are you trying to create a standard page using php scripting<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head>......in php this would be<?phpecho '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'echo '\r\n<html>\r\n<head>\r\n'....?>or<?phpprint "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"print "\r\n<html>\r\n<head>\r\n"....?>echo and print are interchangable in this application, and in the second one ive used only double quotes and \" for any internate double quotes for the printed string. Link to comment Share on other sites More sharing options...
Chozo4 Posted May 1, 2007 Share Posted May 1, 2007 (edited) There is a list of available doctypes at the following pages:http://hsivonen.iki.fi/doctype/ (contains more in depth info)http://www.w3schools.com/tags/tag_doctype.asphttp://htmlhelp.com/tools/validator/doctype.htmlAs for outputting the doctype...You can use the method phkninja declares or you can just add it in to the very top of your PHP outside the php tags. Such as:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html><head><?//insert your php coding here?>Php will output anything not in php tags just as it is. Thus allowing you to output non-dynamic html without the fuss of having to enclose it in a variable. Also to note - if you are not sticking to a strict standard and wish for alot of flexibility, I would personally recommend using HTML 4.01 transitional. Edited May 1, 2007 by Chozo4 Link to comment Share on other sites More sharing options...
ripken204 Posted May 1, 2007 Share Posted May 1, 2007 where exactly are you validating your code for php? ive looked before but i could find a website that validated php, not even W3C.. Link to comment Share on other sites More sharing options...
Chozo4 Posted May 2, 2007 Share Posted May 2, 2007 There is no php validation as far as I know. However, whats validated is the HTML output from the php script. Link to comment Share on other sites More sharing options...
Idontwantspam Posted May 2, 2007 Author Share Posted May 2, 2007 I figured it out! I used the method described by phkninja. I'm not using dynamicy stuff, just using php for the require() function because I am sick of having to copy-and-paste the same header and footer onto every single page. I was being stupid because I just started to use php and I realized that the included pages for the footer and header were full html docs but now I realize it has to be just snippets and the end result is in html form which is what I was validating. It all works now. Thanks all. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now