I would have to say yes it can be done. The way *I* would do it is like this:

First, I would drop a .htaccess file that allows the HTML files to run through the PHP parser. Like this AddType application/x-httpd-php .php .html

The in all of the HTML docs it would look like this:

-HTML-
-Head-
-Title-This is a test-Title-
-body-
-h1-<? include('header.inc'); ?>-/h1-

Well, did it work?

-h3-<? include('footer.inc'); ?>-/h3-
-/body-
-/html-


The next question that comes to mind is, are all the headers and footers static? Or will they rotate?


You will have to have that php code in your HTML docs, otherwise they won't know how to add the header and footer.

Wendell Brown wrote:

Ok guys, I think I have a challenge for you (actually, I don't think
this can be done, but I've been proven wrong every time I've made that
assumption with php in the past, so I'll ask anyway).  Here's the
question:

Is there a way to have php insert headers and/or footers into all of
the html files in a given directory on the fly (not actually modifying
the files)?  And by this I mean take an existing valid HTML file and
add headers and footers and end up with a valid HTML file.

Now, before some of you get trigger happy and tell me to read the
manual and point me to things like .htaccess, auto_prepend_file, google
and the like, think about what I'm really asking.... It needs to
insert the header after the -body- tag and put the footer in before the
-/body- tag. It needs to do this without modifications to the HTML
file.


And yes, I understand that by default HTML files aren't going to be
effected by the auto_prepend_file (since they aren't php files) - so it
will require adding HTML to the list of php parsed file types.

For instance, the goal would be to take the following code:

-HTML-
-Head-
-Title-This is a test-Title-
-body-

Well, did it work?

-/body-
-/html-

and convert it to this:

-HTML-
-Head-
-Title-This is a test-Title-
-body-
-h1-This is a page header-/h1-

Well, did it work?

-h3-This is the footer-/h3-
-/body-
-/html-

Can it be done?  I don't think so, but I leave it up to your wiles to
suggest a solution....

Thanks!!!






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to