Skip to content

Instantly share code, notes, and snippets.

@sajanp
Created December 27, 2012 21:14
Show Gist options
  • Save sajanp/4392038 to your computer and use it in GitHub Desktop.
Save sajanp/4392038 to your computer and use it in GitHub Desktop.
An example of using shorthand if/else to conditionally use an 'active' class on a nav list item.
<li class="<?= ($nav_active == 1 ? 'active' : ''); ?>"><a href="#">Home</a></li>
// If $nav_active equals the integer 1 then echo 'active' else echo '' (nothing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment