It seems to work like this:
Code:
<?php
$test = 'success';
//Case 1. simple variable
$string = 'This is a $test';
// Case 2. Indexed Array variable
$string = 'This is a {$_SERVER["SERVER_NAME"]} ';
echo $string . "<br>";
eval("\$string = \"$string\";");
echo $string . "<br>";
?>
here's a little snippet from the php site which
explains how to do variable substitution in quoted
strings:
,----[
http://www.php.net/manual/en/language.types.string.php ]
| Complex (curly) syntax
|
| This isn't called complex because the syntax is
| complex, but because you can include complex
| expressions this way.
|
| In fact, you can include any value that is in the
| namespace in strings with this syntax. You simply
| write the expression the same way as you would outside
| the string, and then include it in { and }. Since you
| can't escape '{', this syntax will only be recognised
| when the $ is immediately following the {. (Use "{\$"
| or "\{$" to get a literal "{$"). Some examples to make
| it clear:
`----
I hope this helps.
<BroadHint>
If it does, please notice that I have an Affero button.
</BroadHint>