Using inherited variables to generate HTML - a cleaner approach?
<p>My website has navigation at the top of the page that is included in all of my pages. Looks something like:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;My Title&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;? 
 $selected = 'home';
 include('include/header.php'); 
?&gt;
</code></pre>

<p>The <code>header.php</code> file is basically showing the top navigation that is standard on each page.  Above that is a variable that is being inherited by the <code>header.php</code> file to "tell" the header file, where the user is, so that the appropriate navigation tab can be selected.</p>

<p>My <code>header.php</code> file looks something like:</p>

<pre><code>&lt;div id="main_navigation"&gt;
      &lt;ul id="nav"&gt;
        &lt;li&gt;&lt;a href="#"&gt;HOME&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;ABOUT US&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;PURCHASE&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;SOMETHING ELSE&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p>What I want to do is add HTML to the <code>&lt;li&gt;</code> tag to show a css class that will highlight the navigation tab. Is there a more eloquent way to do this besides throwing in this ugly snippit:</p>

<pre><code>&lt;div id="main_navigation"&gt;
      &lt;ul id="nav"&gt;
        &lt;li &lt;? if($selected == 'home'){ print "class = \"select"\"; ?&gt; &gt;&lt;a href="#"&gt;HOME&lt;/a&gt;&lt;/li&gt;
        &lt;li &lt;? if($selected == 'about'){ print "class = \"select"\"; ?&gt; &gt;&lt;a href="#"&gt;ABOUT US&lt;/a&gt;&lt;/li&gt;
        &lt;li &lt;? if($selected == 'purchase'){ print "class = \"select"\"; ?&gt; &gt;&lt;a href="#"&gt;PURCHASE&lt;/a&gt;&lt;/li&gt;
        &lt;li &lt;? if($selected == 'something'){ print "class = \"select"\"; ?&gt; &gt;&lt;a href="#"&gt;SOMETHING ELSE&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
&lt;/div&gt;
</code></pre>
