Memory App
 



Building memory bonds
Php  >     ZCE 5.3  |  Patterns  |  Modern Php Php   >   Operators   >   String

Concatenation

Concatenation operator concatenate right and left arguments.

$a = "a"; 
$b = "b";
echo $a . $b; // ab

Assignment operator

Unlike many other languages (+ in Java), PHP has a special operation that can be used to concatenate two strings together. Dot appends the argument on the right side to the argument on the left side.

$a = "a";
$b = "b";
echo $a .= $b; // ab

Conversion first

It is important to remember that this is the only way. Using the + operator (like in Java) will result in the two strings being first converted to numeric values, and then added together.

$a = "a";
$b = "b";
echo $a += $b; // 0