Bird
0
0

Which of the following is the correct way to access a URL parameter named id using $_GET in PHP?

easy📝 Syntax Q12 of 15
PHP - Superglobals and Web Context
Which of the following is the correct way to access a URL parameter named id using $_GET in PHP?
A$_GET->id
B$GET['id']
Cget['id']
D$_GET['id']
Step-by-Step Solution
Solution:
  1. Step 1: Recall PHP array syntax for superglobals

    $_GET is an associative array, so parameters are accessed with square brackets and quotes.
  2. Step 2: Check each option

    $_GET['id'] uses correct syntax: $_GET['id']. Others use wrong syntax or variable names.
  3. Final Answer:

    $_GET['id'] -> Option D
  4. Quick Check:

    Use square brackets and quotes for $_GET keys [OK]
Quick Trick: Use $_GET['param'] to get URL parameters [OK]
Common Mistakes:
  • Using arrow (->) instead of brackets
  • Missing the dollar sign ($)
  • Using wrong variable names like $GET

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes