Bird
0
0

Which of the following PHP statements correctly concatenates the variables $first and $last?

easy📝 Syntax Q3 of 15
PHP - Operators
Which of the following PHP statements correctly concatenates the variables $first and $last?
Aecho $first . $last;
Becho $first + $last;
Cecho $first & $last;
Decho $first , $last;
Step-by-Step Solution
Solution:
  1. Step 1: Identify concatenation syntax

    PHP concatenates strings using the dot (.) operator.
  2. Step 2: Evaluate options

    echo $first . $last; uses dot correctly; B uses plus (numeric addition), C uses bitwise AND, D uses comma (argument separator).
  3. Final Answer:

    echo $first . $last; -> Option A
  4. Quick Check:

    Dot operator concatenates strings [OK]
Quick Trick: Use dot (.) to join strings in PHP [OK]
Common Mistakes:
  • Using + for string concatenation
  • Using & instead of .
  • Using comma to join strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes