PHP Concatenate Variable - When we have more than one variable and we want to use those variable in one line or paragraph then we used the concatenate variables in php to compile them.
PHP Concatenate Variable - When we have more than one variable and we want to use those variable in one line or paragraph then we used the concatenate variables in php to compile them.PHP Variables Concatenate
When we have more than one variable and we want to use those variable in one line or paragraph then we used the concatenate variables in php to compile them. In other words, it is used when we need to print more than one string where we have other variables or other things as well. The . operator is the string concatenation operator and is very useful for situations where you have too many variables and you want to compile in one. Let see the example :
<?php
$name = "Suraj Mittal";
$age = "22";
echo $name ."is the employee of Rose India ".$age." years old";
?>
The output is: Suraj Mittal is the employee of Rose India 22 years old, getting Rs. 15000 every month and his Employee Id is 12.
Here, in the above example we have more than one variables and we want to show in one line. For this purpose we used concatenate (dot) to compile both of them in one line. You could also write the statement above like that without string concatenating but I think you don't want to write the same code again and again. PHP has a nice way of doing this for you, string concatenating.