Page 1 of 1

Executing PHP from FOPENed files.

Posted: Wed Jul 16, 2003 5:58 pm
by Gen-ik
I am currently in the process of creating a standard set of PHP functions that I will be using as my 'template' for any website designs I do. Each site will be built up from different templates a bit like this forum and other phpBB forums.

One thing I am doing is loading a standard .txt file into PHP, replacing various parts using str_replace(), and then trying to get the file (which is now stored in a variable) into the page.

Getting the file into the page is simple if I use echo() but I have <?php ?> sections in the actual file (which is now stored in a variable remember) which I want to execute as normal. At the moment everything between the PHP tags is being displayed on the page as PHP code and isn't being executed.

Any ideas on how I can remedy this? :?


Thanks.

Posted: Wed Jul 16, 2003 7:34 pm
by Gen-ik
Don't worry I've sorted it...

Code: Select all

<?php

$string = "Some text with <?php echo('php'); ?> in it.";

echo(eval("?>", $string, "<?php"));

?>