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

Is $section required on catalog.php?

In the video, Alena set $section to null in catalog.php. However, what purpose will this serve? As I understand it, we have already set the variable "cat" in the URL, so the conditional:

if ($_GET["cat"] == "books") {
    $pageTitle = "Books";
    $section = "books";
} else if ($_GET["cat"] == "movies") {
    $pageTitle = "Movies";
    $section = "movies";
} else if ($_GET["cat"] == "music") {
    $pageTitle = "Music";
    $section = "music";
}

will always run. Thus, $section will always have a value in catalog.php, and the header is included after the conditional.