Operators And Expressions In Php - Study Mode

[#101] What will be the output of the following PHP code ? <?php $i = 0
$j = 1
$k = 2
print (( + + $i + $j ) >! ( $j - $k ))
?>
Correct Answer

(A) 1

Explanation

Solution: Negation of a number is 0.

[#102] What will be the output of the following PHP code ? <?php $a = 0x6db7
print $a << 6
?>
Correct Answer

(A) 1797568

Explanation

Solution: The output is in decimal.

[#103] What will be the output of the following PHP code ? <?php $a = 'a'
print $a * 2
?>
Correct Answer

(D) 0

Explanation

Solution: Characters cannot be multiplied.

[#104] What will be the output of the following PHP code ? <?php $a = '4'
print + + $a
?>
Correct Answer

(C) 5

Explanation

Solution: The character is type casted to integer before multiplying.

[#105] What will be the output of the following PHP code ? <?php $a = '12345'
print "qwe{$a}rty"
?>
Correct Answer

(A) qwe12345rty

Explanation

Solution: {$}dereferences the variable within.