Concatenation of Two strings in PHP

String Concatenation is done by a dot operator(.) .

Source code :


 <?php
$str1 = "Code";
$str2 = "Cry";
$str3 = $str1.$str2;
echo "Find more programs at ".$str3; //string concatenation operator




Output :

Find more programs at CodeCry

Notes :

We can also concatenate by attaching the arguments on the right side to our already existing string using .= operator (concatenating assignment operator)

example:

$str4 = "Codes from ";
$str4 .= "CodeCry";
echo $str4; // prints Codes from CodeCry..

Output :


                

Comments :