Forum Moderators: coopster

Message Too Old, No Replies

Processing variables in an included page

         

maerk

12:08 am on Mar 18, 2006 (gmt 0)

10+ Year Member



I'm setting up a template based CMS where the template script looks a little like this:

<html>
<head><?php echo $title;?></head>

<body>

<?php
// inserts the content into the template
$page = $_GET['page'];
include("$page.php");
?>

</body>

</html>

$title is defined in the page to be included, but it's not being echoed - is there a way to ensure that variables in the included page are processed by the template script?

ogletree

12:12 am on Mar 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You are asking for it before it exists.

[edited by: ogletree at 12:19 am (utc) on Mar. 18, 2006]

maerk

12:16 am on Mar 18, 2006 (gmt 0)

10+ Year Member



Ah I see, so the "echo $title" would have to come after the "include $page.php". Thanks!

ogletree

12:29 am on Mar 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



this is $page.php

<?php
$title = 'something';
$html = <<<EOT
all page html goes here
EOT;
?>

and this is the template:
<?php
$page = $_get['page'];
include("$page.php");
?>
<html>
<head><?php echo $title;?></head>
<body>
<?php $echo "$html\n";?>
</body>
</html>