title: In PHP is it possible to use a function inside a variable
body: <p>I know in php you can embed variables inside variables, like:</p>
  
  <pre><code>&lt;? $var1 = "I\'m including {$var2} in this variable.."; ?&gt;
  </code></pre>
  
  <p>But I was wondering how, and if it was possible to include a function inside a variable.
  I know I could just write:</p>
  
  <pre><code>&lt;?php
  $var1 = "I\'m including ";
  $var1 .= somefunc();
  $var1 = " in this variable..";
  ?&gt;
  </code></pre>
  
  <p>But what if I have a long variable for output, and I don't want to do this every time, or I want to use multiple functions:</p>
  
  <pre><code>&lt;?php
  $var1 = &lt;&lt;&lt;EOF
      &lt;html lang="en"&gt;
          &lt;head&gt;
              &lt;title&gt;AAAHHHHH&lt;/title&gt;
              &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"&gt;
          &lt;/head&gt;
          &lt;body&gt;
              There is &lt;b&gt;alot&lt;/b&gt; of text and html here... but I want some &lt;i&gt;functions&lt;/i&gt;!
              -somefunc() doesn't work
              -{somefunc()} doesn't work
              -$somefunc() and {$somefunc()} doesn't work of course because a function needs to be a string
              -more non-working: ${somefunc()}
          &lt;/body&gt;
      &lt;/html&gt;
  EOF;
  ?&gt;
  </code></pre>
  
  <p>Or I want dynamic changes in that load of code:</p>
  
  <pre><code>&lt;?
  function somefunc($stuff) {
      $output = "my bold text &lt;b&gt;{$stuff}&lt;/b&gt;.";
      return $output;
  }
  
  $var1 = &lt;&lt;&lt;EOF
      &lt;html lang="en"&gt;
          &lt;head&gt;
              &lt;title&gt;AAAHHHHH&lt;/title&gt;
              &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"&gt;
          &lt;/head&gt;
          &lt;body&gt;
              somefunc("is awesome!") 
              somefunc("is actually not so awesome..") 
              because somefunc("won\'t work due to my problem.")
          &lt;/body&gt;
      &lt;/html&gt;
  EOF;
  ?&gt;
  </code></pre>
  
  <p>Well?</p>