Daniel T
02-12-2005, 05:35 PM
Hey all.
I am in the process of writing a CMS, and I would like to store the HTML for it all in one file, instead of a header and footer file. To do that, I have this file, called struct.php:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title><?php echo $page -> title; ?></title>
<link rel="stylesheet" href="<?php echo $page -> style; ?>" />
</head>
<body>
<!--content-->
</body>
</html>And then the index.php file in the parent directory is as follows:<?php
require_once("class_lib/core.php");
$page = new pageInfo;
list($page_head, $page_foot) = explode("<!--content-->", file_get_contents("html/struct.php"), 2);
echo $page_head;
// this is where all content is outputted
echo $page_foot;
?>
Now, this works all fine and good. But of course, when it outputs the code in the $page_head and $page_foot variables, it doesn't parse the PHP that was within them from the struct.php file. Is it possible to get it to parse the code within the variables?
Thanks in advance,
Dan
I am in the process of writing a CMS, and I would like to store the HTML for it all in one file, instead of a header and footer file. To do that, I have this file, called struct.php:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title><?php echo $page -> title; ?></title>
<link rel="stylesheet" href="<?php echo $page -> style; ?>" />
</head>
<body>
<!--content-->
</body>
</html>And then the index.php file in the parent directory is as follows:<?php
require_once("class_lib/core.php");
$page = new pageInfo;
list($page_head, $page_foot) = explode("<!--content-->", file_get_contents("html/struct.php"), 2);
echo $page_head;
// this is where all content is outputted
echo $page_foot;
?>
Now, this works all fine and good. But of course, when it outputs the code in the $page_head and $page_foot variables, it doesn't parse the PHP that was within them from the struct.php file. Is it possible to get it to parse the code within the variables?
Thanks in advance,
Dan