title: PHP If statement inside For loop
body: <p>The following code gives syntax error because of <code>IF</code>. How can I fix this without removing IF statement?</p>
  
  <pre><code>&lt;?php
      for ($i = 1; $i &lt; 6; $i++){ 
          $data .= 'h'.$i.'{'.    
              if ( !empty ($size) ) {.
              'font-size: ' .$size. ';'.
              }.
          '}';
      }
  ?&gt;
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Parse error: syntax error, unexpected 'if' (T_IF)
  </code></pre>