1
2var str1 = "Hello ";
3var str2 = "world!";
4var res = str1.concat(str2);
5// does not change the existing strings, but
6// returns a new string containing the text
7// of the joined strings.
1<?php
2$a = "Hello ";
3$b = $a . "World!"; // now $b contains "Hello World!"
4
5$a = "Hello ";
6$a .= "World!"; // now $a contains "Hello World!"
7?>
1<?php
2
3// First String
4$a = 'Hello';
5
6// Second String
7$b = 'World!';
8
9// Concatenation Of String
10$c = $a.$b;
11
12// print Concatenate String
13echo " $c \n";
14?>
15
1phpCopy<?php
2$mystring1 = "This is the first string. ";
3$mystring2 = "This is the second string. ";
4$mystring3 = "This is the third string. ";
5$mystring4 = "This is the fourth string. ";
6$mystring5 = "This is the fifth string.";
7
8$mystring1 .= $mystring2 .= $mystring3 .= $mystring4 .= $mystring5;
9echo($mystring1);
10?>
11
1<?php
2 $name = "Paul";
3 $age = 26;
4
5 echo "My name is {$name}, I'm {$age} years old ";