Bird
0
0

Which of the following is the correct way to concatenate two strings $a and $b in PHP?

easy📝 Syntax Q12 of 15
PHP - Operators
Which of the following is the correct way to concatenate two strings $a and $b in PHP?
A$a + $b
B$a . $b
C$a & $b
D$a * $b
Step-by-Step Solution
Solution:
  1. Step 1: Identify the concatenation operator

    PHP uses the dot (.) operator to join strings, so $a . $b is correct.
  2. Step 2: Check other operators

    Plus (+) adds numbers, ampersand (&) is bitwise AND, and asterisk (*) is multiplication.
  3. Final Answer:

    $a . $b -> Option B
  4. Quick Check:

    Dot (.) concatenates strings [OK]
Quick Trick: Use dot (.) to join strings, not plus (+) [OK]
Common Mistakes:
  • Using + instead of . for strings
  • Using & or * operators mistakenly
  • Missing the dot operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes