Forum Moderators: coopster
The functions you need to look into are include/require in the php manual. The basically allow you to include various files within another. So for instance, you could have a file named header.php that contains something like
<?php
defined("SomeText") or die("you cannot call this file directly");
?>
<html>
<head>
<title><?php echo $page_title = isset($page_title) ? $page_title : "mysite.com"; ?></title>
<link rel="stylesheet" src="" />
</head>
<body>
<img src="logo.jpg" alt="Logo" />
<div id="navbar">
<a href="link1.php">Link 1</a>
<a href="link2.php">Link 2</a>
<a href="link3.php">Link 3</a>
</div>
Then do something similar for a file named footer.php
In you myinfo.php you would then do.
<?php
$page_title = "My Info";
define("SomeText", TRUE);
include_once("header.php");
?>
<h1>My Info</h1>
<p>This is whatever information I want to put in here</p>
<?php include_once("footer.php"); ?>
While this answers my question, just out of curiosity: is it possible to automatically modify any html page fetched from your website? So you wouldn't even need include_once on the content page. I think imageshack does this with hosted images...
I think you may be talking more about fopen and fread although I'm not quite sure I get what you mean in the 2nd part, sorry. Take a look at those functions and see if it's what you're after. If not maybe someone else might be able to help you. Either way I think you need to include something whether it's via include or reading a file and adding it's contents.
The other option is something like how phpbb uses template files and placeholders I guess...