PHPGurukul

How to Concatenate two or more string in PHP

We can concatenate two or more string in PHP by concatenation operator(“.”);
Example 1 :

<?php
$string1="Hello";
$string2="World !!";
$string3=$string1.$string2;
echo $string3;
?>

Output : HelloWorld !!
Example 2:  if you want to add space between two strings

<?php
$string1="Hello";
$string2="World !!";
$string3=$string1." ".$string2;
echo $string3;
?>

Output : Hello World !!
Example 3:  Concatenate more than two strings

<?php
$string1="Welcome to";
$string2="PHPGurukul";
$string3="Programming Blog";
$string4=$string1.$string2.$string3;
echo $string4;
?>

Output : Welcome to PHPGurukul Programming Blog

Anuj Kumar

This is Anuj Kumar. I’m a professional web developer with 4+ year experience. I write blogs in my free time. I love to learn new technologies and share with others.
I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials.
.

Recommended Tutorials for you


3 comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.