Re: including HTML

From: Date: Wed, 07 Aug 2002 15:08:30 +0000
Subject: Re: including HTML
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-111519@lists.php.net to get a copy of this message
This is what I normally have on some website! It make it easy to add features and yet not have to update every webpages. Image the nightmare if you have to do that! "Lowell Allen" <la@lowellallen.com> wrote in message news:B975E26B.BCE2%la@lowellallen.com... > > From: "Alexander Ross" <alexross@bleen.net> > > > > Can you include an HTML file up to a certain point. Basically I have a .php > > which I want to have a static header and a static footer (the same as teh > > header and footer of everyother page on this site) and then dynamic content > > in the middle. Is there a way to include each line of html in index.html > > untill I hit a line with <!--HERE --> (or some other comment?). If so, how > > can I then do the opposit and include each line of HTML from <!--HERE--> to > > teh end of the page? > > > If I understand you correctly, the answer is, "yes, it's very easy". When > doing pages that are basically static, I still use PHP for simple includes, > which allows global changes to the header, menu, footer, etc. to be made in > just one place. Just create a file called "output_fns.php" and define > functions to write the HTML fragments you desire, like: > > <? > > function do_html_header($title) > { > ?> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > "http://www.w3.org/TR/html4/loose.dtd"> > <html> > <head> > <title><?=$title?></title> > </head> > <body> > <? > } > > function do_footer() > { > ?> > </body> > </html> > <? > } > > ?> > > Then do pages like: > > <? > require_once("output_fns.php"); > do_html_header("Whatever"); > > // more PHP (or HTML) > > do_footer(); > ?> > > -- > Lowell Allen >

« previous php.general (#111519) next »