concatenate string php code example
Example 1: how to concatenate strings javascript
var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
// does not change the existing strings, but
// returns a new string containing the text
// of the joined strings.
Example 2: php concat
$a = "hello";
$b = "world";
$c = $a . " " . $b;
echo $c; // hello world
Example 3: php append string
<?php
$a = "Hello ";
$b = $a . "World!"; // now $b contains "Hello World!"
$a = "Hello ";
$a .= "World!"; // now $a contains "Hello World!"
?>
Example 4: php connect strings
$string3 = $string1 . $string2;
Example 5: php concatenate and add
this is inside for or foreach loop
# For concatenate use .=
$var .= 'string';
# For adding the VALUES use +=
$var += 1;
Example 6: concatenate string php
<?php
// First String
$a = 'Hello';
// Second String
$b = 'World!';
// Concatenation Of String
$c = $a.$b;
// print Concatenate String
echo " $c \n";
?>