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

PHP Basics / Fundamentals

I'd love a track with PHP Basics / Fundamentals. I'm a total newb at PHP, never tried it before and I had hard time understanding the $_POST,SERVER,GET in the Shirts 4 Mike project. I'd like to know what each do and so on.

2 Answers

$_POST: This is an associative array that contains values when an html form is submitted using the POST method and your PHP script is the action. These are not visible in the query string of the URI.

$_GET: This is an associative array that contains values when you use the query string of a URI to pass values to your script. This can be through a form submitted using the GET method or by simply hitting the PHP page with query string variables set such as example.com/test.php?var1=bob.

$_SERVER: This is an associative array that contains a ton of information provided by the server PHP is running on. This will have values such as the headers sent by the page that requested you PHP script, the paths to your script and root level directories, the type of browser the client is using, etc.

For more information on any of these variables see the PHP manual at http://www.php.net.

Nice, thanks for the answer! Very helpful :-)