Operators And Expressions In Php - Study Mode

[#61] What will be the output of the following PHP code ? <?php $one = "one"
$two = "two"
print( $one,$two )
?>
Correct Answer

(D) error

Explanation

Solution: The above syntax will produce an error, unlike the echo statement.

[#62] What will be the output of the following PHP code ? <?php $color = "red"
$color = "green"
echo "$color"
?>
Correct Answer

(B) green

Explanation

Solution: The variable contains the last value which has been assigned.

[#63] What will be the output of the following PHP code ? <?php $color1 = "red"
$color2 = "green"
echo "$color1" . "$color2"
?>
Correct Answer

(D) redgreen

Explanation

Solution: The . operator is used to join to strings.

[#64] What will be the output of the following PHP code ? <?php $color1 = "red"
$color2 = "green"
echo "$color1" + "$color2"
?>
Correct Answer

(C) 0

Explanation

Solution: + operator does not join both the strings.

[#65] What will be the output of the following PHP code ? <?php $color1 = "red"
$color2 = "red"
echo "$color1" + "$color2"
?>
Correct Answer

(C) 0

Explanation

Solution: + does not return 1 if the variables are equal.