title: HTML within PHP
body: <p>I usually create modular websites, each part of the website being a .php file which will be included in the main pages.</p>
  
  <p>Is it "better" to output HTML within PHP files using <code>echo</code> or to close each time the php tag <code>?&gt;</code> and open it each time I need to access a PHP function/variable.</p>
  
  <p><strong>V1:</strong></p>
  
  <pre><code>&lt;?php    
  $v1=$_POST['name'];    
  echo "Your name is".$v1;
  echo $v1." if you want, you can log out";
  ?&gt;
  </code></pre>
  
  <p><strong>V2:</strong></p>
  
  <pre><code>&lt;?php $v1=$_POST['name']; ?&gt;    
  Your name is &lt;?php echo $v1; ?&gt;
  &lt;?php echo $v1;?&gt; if you want, you can log out
  </code></pre>
  
  <p>The thing is that between the php tags there's much more HTML code (echoed) than actual PHP.<br>
  Does it affect the script performance if I close the tags each time? And is it safe to acces variables declared in a previous block of php code?</p>
  
  <p><strong>EDIT1:</strong>
  When closing the php tags isn't the server clearing some cache for that script, or something like that?</p>