Which operator is used to concatenate strings in PHP?
A
+ B
&& C
& D
.
Analysis & Theory
The dot (`.`) operator is used to concatenate strings in PHP.
What is the output of this code?
```
<?php
$a = 'Hello';
$b = 'World';
echo $a . ' ' . $b;
?>
```
A
HelloWorld B
Hello World C
Hello + World D
Hello.World
Analysis & Theory
The code concatenates 'Hello' with a space and 'World', resulting in `Hello World`.
Which operator is used to append and assign a string in PHP?
A
+= B
.= C
++ D
==
Analysis & Theory
The `.=` operator appends the string on the right to the variable on the left.
What is the output of this code?
```
<?php
$x = 'PHP';
$x .= ' Rocks';
echo $x;
?>
```
A
PHP Rocks B
PHP C
Rocks D
Error
Analysis & Theory
`$x .= ' Rocks';` appends ' Rocks' to `$x`, resulting in `PHP Rocks`.
Which of the following correctly concatenates two strings `$a = 'Good';` and `$b = 'Morning';`?
A
$a + $b B
$a . $b C
$a && $b D
$a concat $b
Analysis & Theory
In PHP, `$a . $b` concatenates 'Good' and 'Morning'.
What is the result of this?
```
<?php
echo 'Hello' . 'World';
?>
```
A
Hello World B
HelloWorld C
Hello+World D
Error
Analysis & Theory
There is no space between 'Hello' and 'World', so it outputs `HelloWorld`.
Which line correctly concatenates and assigns 'PHP' and ' is fun' to the variable `$x`?
A
$x = 'PHP' + ' is fun'; B
$x = 'PHP' . ' is fun'; C
$x = 'PHP' && ' is fun'; D
$x = concat('PHP', ' is fun');
Analysis & Theory
`$x = 'PHP' . ' is fun';` correctly concatenates the strings.
What does the `.=` operator do in PHP?
A
Adds numbers B
Compares strings C
Appends a string to an existing string D
Splits a string
Analysis & Theory
`.=` appends and assigns a string to the existing value of a variable.
Choose the correct way to join strings in PHP:
`'Learn'` and `' PHP'`
A
'Learn' + ' PHP' B
'Learn' . ' PHP' C
'Learn' & ' PHP' D
'Learn' && ' PHP'
Analysis & Theory
The dot (`.`) operator is the correct way to concatenate strings in PHP.
Which statement is true about string concatenation in PHP?
A
PHP uses `+` for string concatenation. B
PHP uses `.` for string concatenation. C
PHP does not support string concatenation. D
PHP uses `*` for string concatenation.
Analysis & Theory
PHP uses the dot (`.`) operator for string concatenation.