I have a text file that includes another file near the end of the article…
<p>Text...</p>
<?php require_once($BaseINC."/2B/inc/D/Content/Child/Bits/GZ/TopicLevels.php"); ?>
<p>More text...</p>
I want to put this article into a database table, but database queries don’t display PHP scripts, of course. I discovered that I could replace echo values - e.g. <php echo $BaseURL; ?> - with a simple $BaseURL, then use str_replace to replace it with an actual echo value in my display:
str_replace('$BaseURL', ''.$BaseURL.'', $Text);
But I can’t figure out how to insert an include in my database display. I thought it might be easiest if I first convert the include to an echo value…
$Content = str_replace('$TopicLevels', ''.$TopicLevels.'', $Content);
But how do I write the echo value? I’ve tried various combinations of single quotes, double quotes and back slashes. But I suspect I’m using the wrong approach to begin with.
$TopicLevels = '.<?php require_once($BaseINC."/2B/inc/D/Content/Child/Bits/GZ/TopicLevels.php"); ?>.';
$Content = str_replace('$TopicLevels', ''.$TopicLevels.'', $Content);
(I should explain that my include contains a variable ($BaseINC) to allow for different locations of includes 1) on my Mac laptop, 2) on a Windows machine and 3) online.)
Thanks.