[thelist] PHP - Variables in a literal string

Quicksilver qsfc at home.com
Fri Jun 1 23:57:09 CDT 2001


The following is just an example, I know that if the situation were similar
to the example that there would be much better ways of accomplishing the
task.  The example, however, is for simplicity's sake.

// Ok, say I have a variable:
$foo = 'hi there';

// And I have a literal string:
$moo = 'I would like to say $foo';

When echoed, the variable $moo says exactly what I typed... my question is
this: How can I make it evaluate the $moo string so that when echoed, it
will display "I would like to say hi there"?

I know there is an eval() function in PHP, and I've read the entry in the
manual on it, but there must be some concept I'm not grasping or something
I've overlooked, because I haven't been able to make it work this way.

Thanks as always,
- Linus





More information about the thelist mailing list