Concatenation is the process of joining multiple strings into one.In PHP concatenate strings is doing by concatenation operator ( “.” dot symbol ).Using of concatenation is highly used one in PHP programs. We need to use this for string concatenations and for printing the results in desired order etc.
Here is one Sample PHP program with Concatenate strings using concatenation operator
<?php $variable_1 = "Syam"; $variable_2 = "is a PHP professional"; $variable_3 = "From India"; echo $variable_1." ".$variable_2." ".$variable_3; ?>
Output of this PHP program will look like
Syam is a PHP professional From India
In Some other cases we need to store the concatenated strings as a variable
See the following code
<?php $variable_1 = "Syam"; $variable_2 = "is a PHP professional"; $variable_3 = "From India"; $variable_4 = $variable_1." ".$variable_2." ".$variable_3; echo $variable_4; ?>
In this code concatenated string is stored in the variable “$variable_4” for later use in the program. Above code will ouput the same result as our previous example.