String variables are variables that contain text (characters).
PHP has many functions that can help you manipulate the string you have created.
Joining strings together
In PHP you can join two or more string together very easily. You can do this by using a dot (” . “).
In the example below, I’ve declared two strings and in the third string I have joined the first two together.
$string1 = "Hey there ";
$string2 = "How are you?";
$string3 = $string1.$string2;
$string3 will now equal to “Hey there How are you?”.
Here’s another example of joining strings. In this example, I have declared two strings and then joined the first string onto the end of the second string.
$string1 = "hot";
$string2 = "Today is so ".$string1;
$string2 will now equal to “Today is so hot”.
$txt2="What a nice day!";
echo $txt1 . " " . $txt2;
The output on screen will be:
Hello World! What a nice day!