Reply to Re: Template Pages with Parse File

Your name:

Reply:


Posted by Chung Leong on 09/30/34 11:26

IWP506@gmail.com wrote:
> So I would structure my links like
> "http://www.domain.com/parse.php?link=aboutUs.html". It would read in
> aboutUs.html, do a string replacement in the appropriate places, then
> output what's left.

You are essentially replicating, in a primitive fashion, the
functionality of the web server and PHP. File look-up is the job of the
web server. Page processing--that's the reason PHP exists in the first
place.

When you have things that happen in multiple places, think function.
What I typically do is have a file that contains the global interface,
with the HTML enclosed inside functions:

<? function PrintHeader($title = "Default title") { ?>
<html>
<head>
<title><?=$title?></title>
.....
<? } ?>
<? function PrintFooter() { ?>
</body>
</html>
<? } ?>

Then I include the file and call the function in each page:

<? require("global.php"); ?>
<? PrintHeader("About Us"); ?>

[ ... page contents ... ]

<? PrintFooter(); ?>

For a more detailed example, go to www.php.net and click on show source.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация