Forum Moderators: mack

Message Too Old, No Replies

What's included in includes?

Headerz

         

madcat

4:10 pm on Sep 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Would you include the DOCTYPE and namespace declarations in a `header` php include? Does it matter if you do, or don't?

griz_fan

5:20 pm on Sep 11, 2003 (gmt 0)

10+ Year Member



I don't think it would matter either way since the includes are processed on the server before the HTML doc gets sent to the client. As long as the result is valid HTML, it really doesn't matter if the DOCTYPE and namespace are in an include file.
Now would I use an include for these? In my case, probably not because I manage most of my sites with a handful of templates and having the DOCTYPE in the template allows HomeSite to account for HTML 4.01 or XHTML 1.0 Transitional and behave accordingly.

jatar_k

5:23 pm on Sep 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you asking whether to have a doctype on your pages at all or just whether it should be in your include file?

If the latter then it depends on how your includes are structured. I usually have my header go from first char of the doc to my content cell <td>

Then my footer from </td> to </html>. If you don't do it that way you may have doctype and title tag on each page and then have from there on in the header. It doesn't make a difference either way. It only depends on how you are doing things.

madcat

5:47 pm on Sep 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No just the latter-

When you say your footer is from the <td> tag to the <html> tag...how is your content being fed into the document (template?)?

jatar_k

5:49 pm on Sep 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the content is on the page itself, so

include $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";

<p>this would be a bunch of content.

include $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php";

all the pages would be some variation of that

madcat

12:06 am on Sep 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, got ya. Thanks-

ergophobe

6:54 am on Sep 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Would you include the DOCTYPE and namespace declarations in a `header` php include?

Frankly, no I wouldn't, not becuase it wouldn't work, but because I like to use a template that defines the structure of the entire page, then use variables and includes to slide headers, footers, navigation, content into that at the very end (i.e. after all processing, so the template is nothing but HTML, includes and echos). That makes the structure very easy to see, makes the page (and thus most pages on the site) easy to completely revamp in terms of the look by changing one file and nicely separates presentation from logic as much as possible.


Does it matter if you do, or don't?

Remember, DOCTYPE is HTML, and your browser doesn't care how that HTML is generated. I could have the following files

file1.php
<? echo "<DOC";?>

file2.php
<? echo "TYPE";?>

... (2004 files deleted for bevity)

file2007.php
<? echo "</html>";?>

file_main.php
<?
include("file1.php");
include("file2.php");
....
include("file2007.php");
?>