PHP String Concatenation

In PHP you can do string concatenation through .(dot) operator. .(dot) operator is a concatenation operator for string values. So when you want to concatenate two or more strings in PHP you can use .(dot) operator. The example of string concatenation is mentioned below: Code


<?php
  $stringVar = "Sunday";
  echo "Today is " . $stringVar;
?>
The output of above mentioned example would be "Today is Sunday".There is another string concatenation example which is mentioned below:

Code

<?php
  $stringVar1 = "Mark";
  $stringVar2 = "John";
  echo $stringVar1 . " and " . $stringVar2 . " are friends.";
?>
The output of above mentioned example will be 'Mark and John are friends.'