title: Why should we separate PHP from HTML
body: <p>I'm rather new to programming and i know how to separate PHP from HTML, but i would like to know if there is any difference in doing </p>
  
  <p>this:</p>
  
  <pre><code>&lt;?php $rand="I love apples" ?&gt;
  &lt;h1&gt;This is a title&lt;/h1&gt;
  &lt;div&gt;
      &lt;p&gt;This is a paragraph&lt;/p&gt;
      &lt;?php echo"The variable contains the string $rand"; ?&gt;
  &lt;/div&gt;
  ?&gt;
  </code></pre>
  
  <p>compared to doing this:</p>
  
  <pre><code>&lt;?php
      echo "&lt;h1&gt;This is a title&lt;/h1&gt;";
      echo "&lt;div&gt;";
      echo "&lt;p&gt;This is a paragraph&lt;/p&gt;";
      echo "The variable contains the string $rand";
      echo "&lt;/div&gt;";
  ?&gt;
  </code></pre>
  
  <p>Is there any difference between in performance etc, between splitting the PHP code from the HTML code and just echoing the whole page in php?</p>