1.Concatenate the string (space between each string)
Code Snippet :
<?php
$txt1 = "Sachin";
$txt2 = "Tendulkar";
$result = $txt1.$txt2 ;
echo $result. "\n";
?>
Output: SachinTendulkar
2.Concatenate the string where space exists
Code Snippet :
<?php
$txt1 = "Sachin";
$txt2 = "Tendulkar";
$result = $txt1." ".$txt2;
echo $result. "\n";
?>
Output : Sachin Tendulkar
- Concatenate the string using printf function.
Code Snippet :
<?php
$data1 = "Sachin";
$data2 = "Tendulkar";
printf("%s%s\n",$data1, $data2);
printf("%s %s\n",$data1, $data2);
?>
Output:
SachinTendulkar
Sachin Tendulkar