Hi Kristian,
You're definitely on the right track but just to clarify a few things:
I'm trying to wrap my head around this $_GET function
$_GET is not a function, it's an associative array.
1) If you add a question mark at the end of a URL e.g. "?category=books" - the word after the question mark - "category", becomes a variable and the word "books", becomes its value
Yes.
2) The function takes a string variable name - $_GET["category"]
Looping back to the first statement, $_GET is an associative array, not a function. An array holds a collection of variables, where as a function is for executing a block of code.
3) The function isset(), checks for a variable "category" in the URL
Yes, mostly. isset(...) takes any variable you pass to it, and determines if it's value is NULL or not. For example:
```
/* given the url http://www.mywebsite.com/mypage.php?category=books */
isset($GET["category"]); // returns true, because category is a parameter that gets passed to the $GET array
isset($GET["foobar"]); // returns false, because foobar is not a parameter, so it does not exist in the $GET array
isset($myVar); // returns false because $myVar is not defined.
```
4) If the variable exists in the URL, the $_GET function takes the value from the variable - in this case, "books"
Yep, but to clarify the terminology: "If the parameter exists in the URL, the $_GET array takes the value from the parameter"
5) You can then use a conditional statement to see what the value of "category" is, and run a code block
Precisely!
Here are some documentation links on the relevant topics:
- arrays (http://php.net/manual/en/language.types.array.php)
- functions (http://php.net/manual/en/functions.user-defined.php)
- superglobals (http://php.net/manual/en/language.variables.superglobals.php)
- isset (http://php.net/manual/en/function.isset.php)
Hope that's helpful. Answer from Miguel Canas on teamtreehouse.com
PHP
php.net โบ manual โบ en โบ reserved.variables.get.php
PHP: $_GET - Manual
The above example will output something similar to: Hello Hannes! ... This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods. ... The values in $_GET are automatically passed through urldecode().
00:59
Using PHPโs $_GET to Extract URL Parameters ๐ - YouTube
06:15
PHP $_GET superglobal | PHP for Beginners - Part 13 - YouTube
Domine GET e POST no PHP! Aprenda a Usar $_GET e ...
11:56
Comprendre & utiliser les mรฉthodes GET & POST en PHP ! - YouTube
19:22
PHP: How to Get Data from a Request | PHP get and post form methods ...
Top answer 1 of 2
9
Hi Kristian,
You're definitely on the right track but just to clarify a few things:
I'm trying to wrap my head around this $_GET function
$_GET is not a function, it's an associative array.
1) If you add a question mark at the end of a URL e.g. "?category=books" - the word after the question mark - "category", becomes a variable and the word "books", becomes its value
Yes.
2) The function takes a string variable name - $_GET["category"]
Looping back to the first statement, $_GET is an associative array, not a function. An array holds a collection of variables, where as a function is for executing a block of code.
3) The function isset(), checks for a variable "category" in the URL
Yes, mostly. isset(...) takes any variable you pass to it, and determines if it's value is NULL or not. For example:
```
/* given the url http://www.mywebsite.com/mypage.php?category=books */
isset($GET["category"]); // returns true, because category is a parameter that gets passed to the $GET array
isset($GET["foobar"]); // returns false, because foobar is not a parameter, so it does not exist in the $GET array
isset($myVar); // returns false because $myVar is not defined.
```
4) If the variable exists in the URL, the $_GET function takes the value from the variable - in this case, "books"
Yep, but to clarify the terminology: "If the parameter exists in the URL, the $_GET array takes the value from the parameter"
5) You can then use a conditional statement to see what the value of "category" is, and run a code block
Precisely!
Here are some documentation links on the relevant topics:
- arrays (http://php.net/manual/en/language.types.array.php)
- functions (http://php.net/manual/en/functions.user-defined.php)
- superglobals (http://php.net/manual/en/language.variables.superglobals.php)
- isset (http://php.net/manual/en/function.isset.php)
Hope that's helpful.
2 of 2
0
Kristian,
You're 100% correct and that code will work without any issues! :) If you need help modifying it or adding more, let me know.
-Nick
Call: +917738666252
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Top answer 1 of 2
5
The $_GET superglobal is defined as part of the URL string:
http://example.org/index.php?foo=bar&baz=1
In index.php:
echo $_GET['foo']; // bar
echo $_GET['baz']; // 1
So $_GET is not stored on the server, but is passed with each HTTP request, as is $_POST, but that is passed in the HTTP headers rather than simply appened to the end of the URL.
2 of 2
2
$_GET variables are those passed via the URL, i.e. index.php?foo=bar&baz=qux (foo equals bar, baz equals qux).
These variables are not stored on the server as a part of the session, but rather only exist with that request. If you want to store information on the server as a part of the session, you should use $_SESSION instead, which will exist within the current session, regardless of the request.
Readthedocs
php-dictionary.readthedocs.io โบ en โบ latest โบ dictionary โบ $_get.ini.html
$_GET - The PHP dictionary - 1.1.31
Redirecting to... /en/latest/index/$_get.html
Educative
educative.io โบ answers โบ php-get
PHP $_GET
August 28, 2020 - The difference between $_GET and $_POST is that the former uses URL parameters to pass form data, while the latter uses the HTTP POST method. Suppose a user visits the URL: http://example.com/?name=John&age=25.
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
CodeWithHarry
codewithharry.com โบ tutorial โบ php-get
$_GET | PHP Tutorial | CodeWithHarry
We can access the values in name_get.php with the $_GET superglobal.
Tutorialspoint
tutorialspoint.com โบ php โบ php_get_post.htm
PHP - GET & POST
The PHP provides $_GET associative array to access all the sent information using GET method. Try out following example by putting the source code in test.php script.
YouTube
youtube.com โบ watch
PHP Tutorial for Beginners 17 # Using $_GET Variables in PHP - YouTube
get - PHP $_GET Variablephp - How to set $_GET variablePHP - easiest way to get $_GET parameters string as writtenPHP: $_GET php $_requestphp $_get arrayphp ...
Published: August 6, 2014
W3Schools
w3schools.sinsixx.com โบ php โบ php_get.asp.htm
PHP GET - SinSiXX - W3Schools
Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.
YouTube
youtube.com โบ bro code
PHP $_GET and $_POST explained - YouTube
PHP get and post super global variables00:00:00 intro00:02:53 $_GET00:05:30 $_POST00:07:00 exercise
Published: May 20, 2024
Views: 12K
W3Schools
w3schools.in โบ php โบ get-post
PHP GET and POST - W3schools
$_GET and $_POST are Superglobal variables in PHP which used to collect data from HTML form and URL. This chapter shows how to collect submitted form-data from users by using POST and GET method. The example below contains an HTML form with two input fields, and a submit button:
Coddy.Tech
coddy.tech โบ docs โบ php โบ $_get and $_post
PHP $_GET and $_POST: Read Query Strings and Form Data
3 weeks ago - Run the block, then click the links: each click runs the script again with $_GET filled from the link's query string. <?php $languages = ['php' => 'PHP', 'python' => 'Python', 'sql' => 'SQL']; $lang = $_GET['lang'] ??