0
0
PHPprogramming~5 mins

$_GET for URL parameters in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the $_GET superglobal in PHP?

The $_GET superglobal is used to collect data sent in the URL parameters (query string) of an HTTP GET request.

Click to reveal answer
beginner
How do you access a URL parameter named name using $_GET?

You access it by using $_GET['name']. For example, if the URL is example.com?name=John, then $_GET['name'] will be John.

Click to reveal answer
beginner
What will $_GET contain if the URL is example.com?page=3&sort=asc?

$_GET will be an associative array with keys and values: ['page' => '3', 'sort' => 'asc'].

Click to reveal answer
intermediate
Why should you validate or sanitize data from $_GET before using it?

Because URL parameters come from the user and can be manipulated, they may contain harmful or unexpected data. Validating or sanitizing helps prevent security issues like XSS or SQL injection.

Click to reveal answer
beginner
How can you check if a URL parameter exists before using it?

You can use isset($_GET['param_name']) to check if the parameter exists to avoid errors when accessing it.

Click to reveal answer
What does $_GET['id'] represent in PHP?
AA cookie named 'id'
BThe value of the URL parameter named 'id'
CA session variable named 'id'
DA POST form field named 'id'
If the URL is example.com?color=blue, what will isset($_GET['color']) return?
Aerror
Bfalse
Cnull
Dtrue
Which HTTP method sends data visible in the URL?
AGET
BPOST
CPUT
DDELETE
Why should you never trust data from $_GET directly?
AIt is only accessible by the server
BIt is always encrypted
CIt can be manipulated by users
DIt is always empty
What type of data structure is $_GET in PHP?
AAssociative array
BIndexed array
CObject
DString
Explain how to retrieve and safely use a URL parameter in PHP using $_GET.
Think about checking existence and cleaning the data before use.
You got /4 concepts.
    Describe what happens when a user visits a URL with parameters and how PHP makes those parameters available.
    Focus on the flow from URL to PHP variable.
    You got /4 concepts.