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 trialAlex Forseth
8,017 PointsWhere 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.
1 Answer
Jennifer Nordell
Treehouse TeacherHi 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!