Hello,
I'm running PHP 4.2 and apache 2.0.40 on RedHat 9.0
I have a class called Page that generates web pages using page-specific variables which are passed as attributes to an instance of the class Page. The attribute Content holds most of a particular page's content. Here's a little bit of the code flow
In page.php which is the script that is the class Page.
<?php
class Page
{
[SNIP]
// The main content of the page
var $Content;
[SNIP]
// an accessor function for Content
function setContent ($PageContent)
{
$this->Content = $PageContent;
}
[SNIP]
// This function displays the page
function displayPage()
{
[SNIP]
echo "\n \n \n <!-- BEGIN PAGE-SPECIFIC CONTENT --> \n"
."<div id=\"content\"> \n \n";
echo $this->Content;
echo "\n \n</div> \n"
."<!-- END PAGE-SPECIFIC CONTENT --> \n \n \n";
[SNIP]
}
[SNIP]
} // End of class page
?>
In a particular web page I instantiate a new object and provide page-specific settings.
<?php
// call the class which generates the page
require ('page.php');
// create a new Page object
$currentPage = new Page();
[SNIP]
// Page-specific settings
$currentPage -> setContent('<p> A bunch of HTML</p>');
// Display the page
$currentPage ->displayPage();
?>
The above works very well as long as $currentPage -> setContent ('') holds only HTML. However, I have not found a way to get PHP code inside $currentPage -> setContent ('') processed by the PHP module.
This doesn't work
$currentPage -> setContent ('<?php $bar ="foo"; echo "$bar"; ?>')
It seems that I am missing something basic. Any ideas?
Thanks for taking the time to read this.
Chemist