title: Parse variables into echo string
body: <p>I'm trying to use PHP variables into echoed file, and couldn't get where is a trouble at first using that script:</p>
  
  <pre><code>$head = new mod_head("head.php");
  $id="ASDSSgdfsfsdfS";
  echo $head;
  </code></pre>
  
  <p>mod_head class:</p>
  
  <pre><code>class mod_head
  {
  private $out="";
  function __construct($arg)
  {
  $this-&gt;out=$this-&gt;parts($arg);
  }
  public function __toString()
  {
  return $this-&gt;out;
  }
  private function parts($file)
  {
  return fread(@fopen(PATH . "parts/".$file, 'r'), filesize(PATH . "parts/".$file));
  }
  }
  </code></pre>
  
  <p>and the file is "head.php"</p>
  
  <pre><code>&lt;h1&gt;&lt;center style="background:orange; border-radius:15px;"&gt;LOGO&lt;/center&gt;&lt;/h1&gt;
  &lt;br&gt;&lt;?php print_r($id)?&gt;
  &lt;div&gt;BANNER &lt;div&gt;$id &lt;?php echo $id ;?&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>i dont want to create global vars, why it doest echo $id var?</p>