Forum Moderators: coopster

Message Too Old, No Replies

CSS and header includes

         

Kysmiley

8:40 pm on Dec 5, 2004 (gmt 0)

10+ Year Member



When doing an include header.inc file for a PHP script
is it better to put the opening html tages in the script of the header
like.
####
<html>
<head>

<title></title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
##########
with a link to the CSS file or is it better include those tags and link in the header.inc file?
Or one other option is it better to do away with the external CSS file and place the CSS coding right in the header.inc file
How do others do it and does it make a difference to PHP how it is done.
Pat

Salsa

12:04 am on Dec 6, 2004 (gmt 0)

10+ Year Member



In the header.inc, I'd start start from the beginning, with doc type, <html>... right up where you begin the page's content. The more you can include via your include file, the less redundancy you'll require on individual pages. As for CSS, I would always recommend linking to it if SEO is important to you. Otherwise, your most important content will appear to be burried deeper within the html code from many spiders' perspectives.

To take it a step farther, rather than making separate files for header.inc and footer.inc..., the way I generally do it is to make a common.inc.php file that includes functions that include the necessary code for top(), left(), right(), bottom()--plus other functions that are likely to be common to all pages. That way, instead of having to include a zillion single purpose files, you can include one file and call the various functions as appropriate.

A final note: Always name your include files with a PHP parsed extension: e.g., header.inc.php, not header.inc. Otherwise, some curious surfer might request your header.inc file and be able to see your raw code because, as only a .inc file, it won't be parsed by PHP.

Kysmiley

1:58 am on Dec 8, 2004 (gmt 0)

10+ Year Member



thank-you Salsa for the very informative response again.
Pat