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 Build a Basic PHP Website (2018) Building a Media Library in PHP Working with _GET Variables

Alex Forseth
Alex Forseth
8,017 Points

Where is the cat variable?

One thing that threw me off a bit was trying to understand where the "cat" variable comes into play.

Did we already make this variable? I am not sure of its origin and it relevance to this course. It would help with understanding this video a little better -

Any help would be great. Thanks.

video link https://teamtreehouse.com/library/build-a-basic-php-website/building-a-media-library-in-php/working-with-get-variables

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The variable might not be obvious at first. This is specified in the href attribute in the header.php file. She covers this briefly at about 0:15 - 0:20 of the video.

In the header.php file we can find this example:

 <li class="books"><a href="catalog.php?cat=books">Books</a></li>

We could have also said:

 <li class="books"><a href="catalog.php?category=books">Books</a></li>

These are sent along in the HTTP request. The $_GET is a special PHP variable that specifically handles variables sent to the server in this manner. Had we used the second version, then we would need $_GET["category"].

Hope this helps! :sparkles: