PHP Concat Strings

Concat Strings

Two strings can be concatenated by using the operator dot (.). Let’s see this with an example:

<?php $str1="Learn"; $str2="PHP"; echo $str1.$str2; ?>

The result for the above echo statement will be:


Now look at the script given below:

<?php $str1="Learn"; $str2="PHP"; echo $str1." ".$str2; ?>

The result of this script will be:

Learn PHP

Here, we used the concatenation operator twice to include another string i.e. a blank.

If you have found my website useful, please consider buying me a coffee below 😉