Concatenation in PHP

author details
AdiPie
13th Jan 2021
1 min read
Image
Concatenation in PHP

Concatenation

PHP having various types of operators with different functionalities. Operators enable us to achieve arithmetic operations, string concatenation, value comparison, boolean algorithms, etc. In this blog, we will get to know more about string concatenation.

Let us discuss the types of string operators, They are two types:

  • Concatenation Operator
  • Concatenating Assignment operator

Concatenation Operator

Concatenation operator string merges two values of a string and creates it as a new string. The symbol of the concatenation operator is  (".")

<?php
$first = 'Hello';
$second = 'Folks';
$third = $first.$second;
echo " $third ";
?>

The result is : HelloFolks

Concatenating Assignment operator

This related operation adds the argument of the right side with the left argument. The symbol of concatenating assignment operator is (".=").

<?php
$first = 'Hello';
$second = 'Folks';
$first .= $second;
echo " $first ";
?>

The result is : HelloFolks