Concatenation

The process of concatenation consists of joining two or more variables separating them with a dot. Suppose you want to echo out the following “My age is 25”, you can do it this way:

<?php

$text = “My age is”;

$age = 25;

echo $text.$age;

?>

You can do this with how many more variables do you want, also you can achieve the same result as the code above by doing this thing:

<?php

$age = 25;

echo “My age is”.$age;

?>

 This time the text is not included in a variable and you use it just in this echo. The benefit of using variables is that you store some information in it and you can reuse it whenever you just just by calling that variable also you can alter it and play with it however you want inside your code.

 

Leave a comment