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 trialChristopher Eastridge
3,819 PointsHow does "status" evaluate to "thanks"?
I understand that we are searching $_GET if the status exists first, then we check to see if the "status" == "thanks". Where does "thanks" exist in the code to allow the if statement to execute? I don't understand how "status" can have a value of "thanks" if we didn't declare anything for it.
1 Answer
Andrew Shook
31,709 PointsStatus was set equal to "thanks" a 00:25 in this video. "Thanks" exists a value in the $_GET array, and is put there by adding "?status=thanks" to the end of a url. When Apache fires up PHP, when a PHP script is requested, it takes anything after a question mark, but before a hash tag, and gives it to PHP to parse. PHP parses the string by taking what is to the left of the equals sign and making that the index of the array and taking what is to the right of the equals sign and making that the value. Hope this helps.
Christopher Eastridge
3,819 PointsChristopher Eastridge
3,819 PointsThis couldn't have been a better answer. I thought I figured it out a few minutes ago and started to move on. This answer definitely gave me a better understanding of what is actually happening. Thanks for the help!
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsNope problem, glad I could help.