Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Quick Question on build a simple PHP app

So I've completed the the second chapter of build a simple PHP app ( creating the menu and footer ).

The part of the code that I don't understand is which part made it underlined when i was on the page.

I know that the { echo "on"; } has something to do with it, but I don't understand why it underlines it.

Any help would be awesome. Here's the code at question.

<li class="shirts <?php if ($section == "shirts") { echo "on"; } ?>"><a href="shirts.php">Shirts</a></li>

1 Answer

there is a css class .on where text-decoration: underline is define.

the variable $section is stocking the page name and the if condition is evaluating each link.

then php adds the class .on to the list element if condition is true.

Good response. Gave it a plus one

It's about you setting the $section variable on that page you are on, and the same code in the same header will respond to what you set that one variable too.

Take a look at your source code, and you'll see what HTML the PHP generated.