Bird
0
0

What will the following PHP code output if the URL is page.php?color=blue?

medium📝 Predict Output Q4 of 15
PHP - Superglobals and Web Context
What will the following PHP code output if the URL is page.php?color=blue?
<?php
echo $_GET['color'];
?>
AArray
Bcolor
CUndefined index error
Dblue
Step-by-Step Solution
Solution:
  1. Step 1: Identify the URL parameter

    The URL contains color=blue, so $_GET['color'] holds 'blue'.
  2. Step 2: Output the value

    The code echoes $_GET['color'], so it prints 'blue'.
  3. Final Answer:

    blue -> Option D
  4. Quick Check:

    $_GET['color'] = 'blue' output [OK]
Quick Trick: Echo $_GET['param'] to print URL parameter value [OK]
Common Mistakes:
  • Expecting key name printed
  • Confusing array output
  • Assuming error without parameter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes