php - if statement, same variable -
i'm checking users current page, , applying .css class correct menu item.
my question is, how can best? currently, have this:
$currentpage = $_server['php_self']; if($currentpage == "/prefs.php") $active = "active"; if($currentpage == "/acc.php") $active = "active"; if($currentpage == "/forum.php") $active = "active"; <a href='acc.php' title='sync' aria-hidden='true' class='{$active} tiptip'> <a href='acc.php' title='sync' aria-hidden='true' class='{$active} tiptip'> <a href='forum.php' title='statistics' aria-hidden='true' class='{$active} tiptip'> but add active class anchor elements.
<?php $currentpage = $_server['php_self']; echo "<a href='prefs.php' title='sync' aria-hidden='true' class='" . ($currentpage == '/prefs.php' ? 'active' : '') . " tiptip'> <a href='acc.php' title='sync' aria-hidden='true' class='" . ($currentpage == '/acc.php' ? 'active' : '') . " tiptip'> ..."; if don't this, use switch() { case '': break; } setup.
Comments
Post a Comment