Connecting strings together is known as concatenation. The operator to use with this is the period.
The value of $NewString is the combination of $string1 and $string2. This is not addition like in math. This is taking the value of $string2 and plunking it onto the end of $string1.
Hmmm... that doesn't quite look right. There should be a space between the words example and of. Let's add in a space on the connecting code line :
So you can add strings, direct quoted data, and so forth together. Some "real world" example of using this may be to combine a $FirstName and $LastName into one string. There could be many other uses as well.
$NewString = $string1 . $string2;
The value of $NewString is the combination of $string1 and $string2. This is not addition like in math. This is taking the value of $string2 and plunking it onto the end of $string1.
<?php
$string1 = "This is an example";
$string2 = "of connecting strings.";
$NewString = $string1 . $string2;
echo "$NewString";
?>
$string1 = "This is an example";
$string2 = "of connecting strings.";
$NewString = $string1 . $string2;
echo "$NewString";
?>
This is an exampleof connecting strings.
Hmmm... that doesn't quite look right. There should be a space between the words example and of. Let's add in a space on the connecting code line :
$NewString = $string1 . " " . $string2;
This is an example of connecting strings.
So you can add strings, direct quoted data, and so forth together. Some "real world" example of using this may be to combine a $FirstName and $LastName into one string. There could be many other uses as well.

