Is the following code legitimate? <li<?php if ($page_identity == "About Us") echo " id=\"currentpage\""; ?>> <a href="AboutUs.php" title="...">About Us</a> </li> I.e. can I insert the php code within the <li> tag? It seemed to work before but now by text editor (BBedit) doesn't seem to be recognizing it and this is confirmed when I run the code in my browsers. Pitto
Also, must I escape the ">" character in order to print it within an echo statement? Take my previous example, <li<?php if ($page_identity == "About Us") echo " id=\"currentpage\""; ?>> <a href="AboutUs.php" title="...">About Us</a> </li> Could I add a ">" like this(see bold, underlined >), <li<?php if ($page_identity == "About Us") echo " id=\"currentpage\">About Us"; ?>> <a href="AboutUs.php" title="...">About Us</a> </li> or do I need to escape it with a "\"? If this isn't allowed it could be my problem. Thanks again, Pitto
Yes you can drop into PHP. And no you don't have to escape the >. If you did escape the output would be: About Us> About Us . Problem must be somewhere else.
Why not simply echo the '>' as well? <li<?php if ($page_identity == "About Us") { echo " id=\"currentpage\"" . ">"; } ?> <a href="AboutUs.php" title="...">About Us</a> </li> Try that.
Another easiar to read way <?PHP if ($page_identity == "About Us") { $id = 'id="currentpage"'; }else{ $id = '' } ?> <li <?php echo $id;?>> <a href="AboutUs.php" title="...">About Us</a> </li> PHP:
Jason in your example you forgot to add the id attribute for the li tag. It should be: <li id=<?=$id;?>>