Concept Flow - String concatenation operator
Start
Two strings
Use . operator
Combine strings
Result: concatenated string
End
This flow shows how two strings are joined using the dot (.) operator to create one combined string.
<?php $a = "Hello"; $b = " World"; $c = $a . $b; echo $c; ?>
| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Assign string | $a | "Hello" | |
| 2 | Assign string | $b | " World" | |
| 3 | Concatenate $a and $b | $c | "Hello World" | |
| 4 | Print $c | Output | Hello World |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| $a | undefined | "Hello" | "Hello" | "Hello" | "Hello" |
| $b | undefined | undefined | " World" | " World" | " World" |
| $c | undefined | undefined | undefined | "Hello World" | "Hello World" |
PHP uses the dot (.) operator to join strings. Syntax: $combined = $str1 . $str2; It converts non-strings to strings automatically. Plus (+) is NOT for strings in PHP. Result is a new combined string.
.) operator do in PHP?$a and $b in PHP?$greeting = "Hello"; $name = "Alice"; echo $greeting . ", " . $name . "!";
$first = "Good"; $second = "Morning"; echo $first + " " + $second;
$firstName and $lastName with a space between them. Which code correctly does this in PHP?Pass the test and this pattern moves unknown