Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Anthony Fowler6,749 Points
My Code works as shown but I am wondering how or why echo " on" has this effect.
It seems to be that the underlining of the nav element is possibly done through CSS and This echo "on" is possibly creating a class? I don't quite understand what is happening here. Any help would be much appreciated!
Dave Faliskie17,781 Points
The purpose for using the echo " on" is to add the class .on (which just underlines the text) to the nav link if it meets the condition set.
So what that php code is doing is comparing the $section variable, set on each page, to the name of the link. Ex. the $section = 'book' means your on the book page so echo " on". Or in other words if they are the same add the class "on"