title: Using PHP and HTML code together?
body: <p>When using PHP code and HTML throughout the whole page of a website, is it quicker to  state a condition than define the whole page, or keep going back to that condition at different parts of the page? For example:</p>
  
  <pre><code>&lt;?php if(isset($_SESSION['token'])) { ?&gt;
  &lt;html&gt; Lots of HTML &lt;/html&gt;
  &lt;?php } else if (!isset($_SESSION['token'])) { ?&gt;
  &lt;html&gt; Lots of HTML &lt;/html&gt; &lt;?php } ?&gt;
  </code></pre>
  
  <p>So here I'm just basically defining the whole page twice with different stuff depending on whether the user is logged in or not.</p>
  
  <p>Or I could do..</p>
  
  <pre><code>&lt;?php if(isset($_SESSION['token'])) $loggedIn = true; 
  else if (!isset($_SESSION['token'])) $LoggedIn = false; ?&gt;
  
  &lt;html&gt;
  Some HTML stuff ...
  &lt;?php if($LoggedIn == true) echo "&lt;div&gt;You are now logged in&lt;/div&gt;";
  else if($LoggedIn == false) echo "&lt;div&gt;Please log in to continue&lt;/div&gt;"; ?&gt;
  
  Some more HTML ...
  &lt;?php if($LoggedIn == true) // Etc. ?&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>And here I'm just checking back to whether the user is logged in or not within the same HTML tags and displaying the appropriate content.</p>
  
  <p>Also, could anyone tell me whether its better to <code>echo</code> HTML, or just cut off the PHP, use normal HTML and then reopen PHP and close the bracket. </p>
  
  <p>I tried to be as clear as possible but was finding it hard.</p>