Recall & Review
beginner
What is the string concatenation operator in PHP?
The string concatenation operator in PHP is the dot (.) symbol. It joins two or more strings together.
Click to reveal answer
beginner
How do you join the strings "Hello" and "World" in PHP?
You use the concatenation operator like this:
$greeting = "Hello" . " " . "World"; which results in "Hello World".Click to reveal answer
beginner
What will be the output of this PHP code?<br>
$a = "Good";<br>$b = "Morning";<br>echo $a . " " . $b;
The output will be: Good Morning. The dot operator joins the strings and the space " " adds a space between them.
Click to reveal answer
beginner
Can you use the plus (+) operator to concatenate strings in PHP?
No, the plus (+) operator is for numbers only. Using it with strings will cause errors or unexpected results. Use the dot (.) operator for strings.
Click to reveal answer
beginner
How to concatenate multiple strings in PHP in one statement?
You can chain the dot operator like this:<br>
$full = "I" . " " . "love" . " " . "PHP";<br>This results in "I love PHP".Click to reveal answer
Which operator is used to join strings in PHP?
✗ Incorrect
The dot (.) operator is the correct string concatenation operator in PHP.
What will this PHP code output?<br>
echo "Hi" . " " . "there!";
✗ Incorrect
The dot operator joins the strings with a space in between, so the output is 'Hi there!'.
What happens if you use + to join strings in PHP?
✗ Incorrect
The plus (+) operator is for numbers. Using it with strings causes errors or unexpected results.
How to add a space between two concatenated strings in PHP?
✗ Incorrect
You add a space by including it inside a string or concatenating a string with a space " ".
Which of these is a valid PHP string concatenation?
✗ Incorrect
Only the dot (.) operator correctly concatenates strings in PHP.
Explain how to join two strings in PHP and how to include a space between them.
Think about the symbol used to join strings and how to add spaces.
You got /4 concepts.
Describe why the plus (+) operator is not used for string concatenation in PHP.
Consider the difference between numbers and strings in PHP operators.
You got /3 concepts.