Bird
0
0

What will this PHP code output?

medium📝 Predict Output Q5 of 15
PHP - Variables and Data Types
What will this PHP code output?
$message = 'Hello';
$message = $message . ' World';
echo $message;
AHello
BHello World
CHelloWorld
DWorld
Step-by-Step Solution
Solution:
  1. Step 1: Understand string concatenation

    The dot (.) joins 'Hello' and ' World' with a space included.
  2. Step 2: Output the concatenated string

    echo prints 'Hello World' with the space.
  3. Final Answer:

    Hello World -> Option B
  4. Quick Check:

    String concatenation result = 'Hello World' [OK]
Quick Trick: Use . to join strings in PHP [OK]
Common Mistakes:
  • Forgetting space in string
  • Using + instead of .
  • Expecting original string only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes