|
Posted by Chung Leong on 11/21/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.
Navigation:
[Reply to this message]
|