Which of the following is used to concatenate two strings in PHP?
Correct answer
A. .
12 views
A. .
12 views
The dot operator (.) concatenates strings in PHP: "Hello" . " World" gives "Hello World", and .= appends to an existing string.
This differs from JavaScript and Java, where + joins strings. In PHP, + is strictly arithmetic, so using it on text causes type errors or unexpected numeric results.
Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.