Forum Moderators: coopster
I have the need to echo information in various places from within pre-written text drawn from a db table. Text within the DB table is similar to this:
******************
<h1>Privacy Policy for <?php echo $companyName;?>.</h1>
<p>Some text here about some topic from <?php echo $companyName;?> relating to their privacy policy</p>
******************
When the text is displayed everything shows up between the html tags except the echoed variables which I find odd as if I were to type the same thing directly into a page (not drawn from a db table) then the contents of the VARs are displayed as expected.
When I check the source code of the page, the <?php echo $companyName;?> shows up in a pale blue color which I've also never seen before.
The only way I've found to make this work is to embed some kind of symbol (like an '*') where I need the var(s) to show up, draw the info from the table, and then replace the asterisk with the VAR. That works, but jeez, what a pain ... especially if there are numerous places that I need var information to be displayed.
As you can see in the example above, all of my text within the db table is already pre-formatted with html tags. Is this the problem?
Neophyte
Thanks for the tip on the eval() function! Works like a charm!
Follow-on question to you (or anyone else)...
From the documentation, I gather that eval() processes (evaluates) everything within a given string and then returns the string along with the contents of any $var found within the string.
If this is true, I'm imagining that display output may slow down if there was A LOT of text within a string to process.
If this is (at least theoretically) true, then is there another way to echo the contents of a $var found within a string of text drawn from a DB without a noticeable output performance hit?
Noephyte