Dynamically change menu item in PHP
<p>I know very little about PHP, but recently split the menu portion on my static web pages to a header.php and this works. I now want to change the font color of active page. I saw an example here but cannot get the php code to work. Here is my current menu before any changes</p>

<pre><code>&lt;div id="menu"&gt;
     &lt;ul&gt;
         &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="lessons.php"&gt;Lessons&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt;
     &lt;/ul&gt;
&lt;/div&gt; &lt;!-- end menu div --&gt;
</code></pre>

<p>I saw this code in StackOverflow (modified for my menu)</p>

<pre><code>&lt;?php # Using REQUEST_URI
$currentpage = $_SERVER['REQUEST_URI'];?&gt;
&lt;div class="nav"&gt;
    &lt;div class="tab
         &lt;?php
             if(preg_match("/index/i", $currentpage)||($currentpage=="/"))
                 echo " currentpage";
         ?&gt;"&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;
     &lt;/div&gt;
     &lt;div class="tab
         &lt;?php
             if(preg_match("/about/i", $currentpage))
                 echo " currentpage";
         ?&gt;"&gt;&lt;a href="lessons.php"&gt;Lessons&lt;/a&gt;
     &lt;/div&gt;
     &lt;div class="tab
         &lt;?php
             if(preg_match("/contact/i", $currentpage))
                 echo " currentpage";
         ?&gt;"&gt;&lt;a href="contact.php"&gt;Contact&lt;/a&gt;
     &lt;/div&gt;
 &lt;/div&gt; &lt;!--nav--&gt;
</code></pre>

<p>When I tried to substitute the php between the ul and the /ul, I get an error message:
line 2: Undefined Index: REQUEST_URI </p>

<p>I read about REQUEST_URI but do not understand why it is not working. </p>

<p>Any help would be appreciated. Thanks.</p>
