1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which of the following is used to concatenate two strings…

Added 23 Jan 2024

Which of the following is used to concatenate two strings in PHP?

  1. . Correct answer
  2. +
  3. ::
  4. -

Correct answer

A. .

12 views

MCQSEXAM

Explanation

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.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs