title: How do I dynamically insert a CSS class using PHP?
body: <p>What's wrong with the following code? I would like to dynamically insert "current" CSS class when the respective <code>&lt;li&gt;</code> element is clicked. Thanks!</p>
  
  <pre><code>&lt;?php 
  $pg = $_SERVER['PHP_SELF']; 
  ?&gt;
  
  &lt;section&gt;
      &lt;aside&gt;       
          &lt;nav&gt;
              &lt;ul&gt;
                  &lt;li class="&lt;?php if($pg == 'index.php?page=about.php'){echo 'current';} ?&gt;"&gt;&lt;a href="index.php?page=about.php"&gt;About&lt;/a&gt;&lt;/li&gt;                       
              &lt;li class=""&gt;&lt;a href=""&gt;Services&lt;/a&gt;&lt;/li&gt; 
              &lt;/ul&gt;
          &lt;/nav&gt;
      &lt;/aside&gt;
  &lt;section&gt;
  </code></pre>