Bird
0
0

Given $a = "Hello"; and $b = "World";, which code snippet correctly appends $b to $a?

hard📝 Application Q9 of 15
PHP - Operators
Given $a = "Hello"; and $b = "World";, which code snippet correctly appends $b to $a?
A$a = $a . $b;
B$a += $b;
C$a = $a + $b;
D$a = $a & $b;
Step-by-Step Solution
Solution:
  1. Step 1: Understand string append in PHP

    Use dot (.) operator to join strings and assign back.
  2. Step 2: Identify correct assignment

    $a = $a . $b; appends $b to $a correctly.
  3. Final Answer:

    $a = $a . $b; -> Option A
  4. Quick Check:

    Append strings with dot and assignment [OK]
Quick Trick: Use $a = $a . $b to append strings [OK]
Common Mistakes:
  • Using += or + for strings
  • Using & operator
  • Incorrect assignment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes