title: How to execute and get content of a .php file in a variable?
body: <p>I want to get contents of a .php file in a variable on other page.</p>
  
  <p>I have two files, <code>myfile1.php</code> and <code>myfile2.php</code>. </p>
  
  <p><strong>myfile2.php</strong></p>
  
  <pre><code>&lt;?PHP
      $myvar="prashant"; // 
      echo $myvar;
  ?&gt;
  </code></pre>
  
  <p>Now I want to get the value echoed by the myfile2.php in an variable in myfile1.php, I have tried the follwing way, but its taking all the contents including php tag () also.</p>
  
  <pre><code>&lt;?PHP
      $root_var .= file_get_contents($_SERVER['DOCUMENT_ROOT']."/myfile2.php", true);
  ?&gt;
  </code></pre>
  
  <p>Please tell me how I can get contents returned by one PHP file into a variable defined in another PHP file.</p>
  
  <p>Thanks</p>