How add class='active' to html menu with php
<p>I want to put my html navigation in a separate php file so when I need to edit it, I only have to edit it once. The problem starts when I want to add the class active to the active page. </p>

<p>I've got three pages and one common file.</p>

<p><em><strong>common.php :</em></strong></p>

<pre><code>&lt;?php 
$nav = &lt;&lt;&lt;EOD
   &lt;div id="nav"&gt;
        &lt;ul&gt;
           &lt;li&gt;&lt;a &lt;? if($page == 'one'): ?&gt; class="active"&lt;? endif ?&gt; href="index.php"&gt;Tab1&lt;/a&gt;/&lt;/li&gt;
           &lt;li&gt;&lt;a href="two.php"&gt;Tab2&lt;/a&gt;&lt;/li&gt;
           &lt;li&gt;&lt;a href="three.php"&gt;Tab3&lt;/a&gt;&lt;/li&gt;
       &lt;/ul&gt;
    &lt;/div&gt;
EOD;
?&gt;
</code></pre>

<p><em><strong>index.php :</em></strong> 
All three pages are identical except their $page is different on each page.</p>

<pre><code>  &lt;?php
     $page = 'one';      
     require_once('common.php');
    ?&gt;
    &lt;html&gt;
       &lt;head&gt;&lt;/head&gt;
       &lt;body&gt;
          &lt;?php echo $nav; ?&gt;
       &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>This simply won't work unless I put my nav on each page, but then the whole purpose of separating the nav from all pages is ruined.</p>

<p>Is what I want to accomplish even possible? What am I doing wrong?</p>

<p>Thanks</p>

<p>EDIT: When doing this, the php code inside the li don't seem to run, it's just being printed as if it was html </p>
