Trouble understanding PHP template concepts (not engine specific)
<p>I am in the process of creating my first web app and I am at a point where I have some basic CRUD functionality. </p>

<p>I got tired of looking at the default browser styling so I decided to use Twitter Bootstrap (TBS) to implement some basic styling. </p>

<p>Once I started adding all the extra divs and classes required to implement TBS, I realized that this would be a real pain if I had to do this for every page in my site. I figured some sort of templating was the answer. </p>

<p>I have never used a template engine but I think I have a very basic understanding of templating outside the scope of any particular templating engine. </p>

<p>The two basic methods of templating that I think I understand are: </p>

<ol>
<li>Using variables in the template; or  </li>
<li>Using the find and replace method (which I believe Smarty uses if I'm not mistaken)</li>
</ol>

<p>However, all of the examples I've seen show a very basic HTML template with some very simple variable or search/replace methods. </p>

<p>In my code though it doesn't seem that simple. For instance, my page may start out with all of the TBS divs and other tags, followed by some PHP code to show query results, followed by more tags to close the TBS divs.  Then I may have more PHP code followed by more HTML. </p>

<p>In the variable replacement method of templating that I've seen, they simply replace a variable with some echoed text. But it's not that easy when your PHP code is more complex.</p>

<pre><code>&lt;?php include_once "includes/header.php" ?&gt;
&lt;body style="padding-top:60px";&gt;&lt;!--This is necessary for the cerulean bootstrap theme--&gt;
&lt;?php include_once "includes/beginning_scripts.php" ?&gt;
&lt;div class="container-fluid"&gt;
&lt;div class="row-fluid"&gt;
    &lt;div class="span3"&gt;
    &lt;/div&gt;&lt;!--class="span3"--&gt;
    &lt;div class="span3"&gt;
        &lt;div class="navbar navbar-fixed-top"&gt;
              &lt;div class="navbar-inner"&gt;
                &lt;a class="brand" href="index.php" style="padding-left:25px;"&gt;Timeclock&lt;/a&gt;
                &lt;ul class="nav"&gt;
                  &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li class="active"&gt;&lt;a href="manager.php"&gt;Manager View&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="admin.php"&gt;Admin&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="logout.php"&gt;Log Out&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
              &lt;/div&gt;&lt;!--class="navbar-inner"--&gt;
        &lt;/div&gt;&lt;!--class="navbar"--&gt;

PHP CODE HERE

    &lt;/div&gt;&lt;!--class="span3"--&gt;
    &lt;div class="span3"&gt;
    &lt;/div&gt;&lt;!--class="span3"--&gt;
&lt;/div&gt;&lt;!--class="row-fluid"--&gt;

&lt;div class="row-fluid"&gt;
    &lt;div class="span2"&gt;
    &lt;/div&gt;&lt;!--class="span2"--&gt;
    &lt;div class="span8"&gt;

PHP CODE HERE

    &lt;/div&gt;&lt;!--class="span8"--&gt;
    &lt;div class="span2"&gt;
    &lt;/div&gt;&lt;!--class="span2"--&gt;
&lt;/div&gt;&lt;!--class="row-fluid"--&gt;
&lt;/div&gt;&lt;!--class="container-fluid--&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
