Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q4 of 15
PHP - Basics and Execution Model
What will be the output of this PHP code?
<?php
echo "Hello" . " World!";
?>
AError: Invalid concatenation
BHelloWorld!
CHello World!
DHello . World!
Step-by-Step Solution
Solution:
  1. Step 1: Understand string concatenation in PHP

    The dot . operator joins two strings with no extra spaces.
  2. Step 2: Analyze the given strings

    "Hello" and " World!" concatenated produce "Hello World!" with a space included in second string.
  3. Final Answer:

    Hello World! -> Option C
  4. Quick Check:

    String concatenation = Hello World! [OK]
Quick Trick: Use dot (.) to join strings in PHP [OK]
Common Mistakes:
  • Forgetting space in strings
  • Using + instead of . for concatenation
  • Expecting dot to print literally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes