title: How to run a multiline PHP script in HTML page?
body: <p>I am trying to wrap my head around php and html, and wanted to ask some help with what I guess are basics.</p>
  
  <p>I am aware that you can run a php script on a single line in a .html page with  tags. The problem comes when I have a longer script on multiple lines (It generates a table) that I run from localhost:</p>
  
  <pre><code> &lt;?php
    $rows = 10; // define number of rows
    $cols = 10;// define number of columns
  
    echo "&lt;table border='1'&gt;"; 
  
    for($tr=1;$tr&lt;=$rows;$tr++){ 
  
    echo "&lt;tr&gt;"; 
      for($td=1;$td&lt;=$cols;$td++){ 
             echo "&lt;td&gt;Fill&lt;/td&gt;"; 
      } 
    echo "&lt;/tr&gt;"; 
    } 
  
    echo "&lt;/table&gt;"; 
    ?&gt;
  </code></pre>
  
  <p>The above will come out as plain text after first ">" sign, so I guess for some reason the page reads it as I close the php snippet and executes rest as plain HTML (I run the file through apache). I am aware that you can rename the file to .php instead, and get whole thing working, but I want to understand know how PHP behave on HTML pages. </p>
  
  <p>So I have two questions:</p>
  
  <p>1) Is it possible to make the .html read the above code snippet without breaking it apart? I've tried htmlspecialchars, didn't help. </p>
  
  <p>2) Is it possible to have the above snippet as a separate .php file, that I call from .html page like I can call a javascript function? I've tried <code>&lt;?php include 'field.php';?&gt;</code> which didn't work. I've looked into .htaccess, but it seems that's a solution for live versions, which didn't work for me. </p>
  
  <p>Thank you!</p>