Hi.
Please enclose your posted code in [code] tags (See
How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.
Moderator
As for your problem.
The two previous posts will fix your problem, but they do not really explain it.
The reason it didn't work was because you used single-quotes around your $str variable. Single quotes will instruct PHP to print exactly what you put inside them, and not to evaluate any variable names within them.
Double quotes, however, will evaluate variable names and replace them with their values.
For example:
-
$str = "My string";
-
-
echo "$str"; # Prints: My string
-
echo '$str'; # Prints: $str
-