title: Accessing PHP variable inside a string stored in variable
body: <p>I am trying to resolve value for the PHP variable stored as a string in a database field.
  I know that using echo with double quotes detects PHP variable and prints it's value. I tried wrapping the value in the database inside {} as well.
  But I am not getting the same results from the string stored in a variable ($str2 in this case). $str2 stores a result of a database query.</p>
  <p>I am using the Yii2 framework here. Is there any way to do the same in core PHP or in Yii2? I tried Herodoc as well.</p>
  <p>Edit: The string stored in $str2 has some HTML tags as well, that is why I cannot use <code>eval</code>.</p>
  <pre><code>$str = 'foo';
  $str2 = SomeClass::getValue($someParam); 
      //returns string with variable names in it i.e. '&lt;h1&gt; somestring: $str&lt;/h1&gt;' or '&lt;h1&gt; somestring: {$str}&lt;/h1&gt;'
  
  echo '{$str}'; //prints $str
  echo &quot;{$str}&quot;; // prints foo
  echo &quot;{$str2}&quot;; //prints $str or {$str} , why??
  
  echo &lt;&lt;&lt;EOT
  &quot;{$str2}&quot;
  EOT;   //prints $str or {$str} , why??
  </code></pre>