Operators And Expressions In Php - Study Mode

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

(B) qwe{$a}rty

Explanation

Solution: qwe{$a}rty, single quotes are not parsed.

[#117] What will be the output of the following PHP code ? <?php $a = '12345'
echo "qwe$arty"
?>
Correct Answer

(C) qwe

Explanation

Solution: qwe, because $a became $arty, which is undefined.

[#118] What is the output of given statement? Print 17 % 3
Correct Answer

(B) 2

[#119] What will be the output of the following PHP code ? <?php echo $x -- != ++ $x
?>
Correct Answer

(A) 1

Explanation

Solution: Automatically x is declared and initialized to 0,then decremented and compared with its increments, thus returns 1.

[#120] What will be the output of the following PHP code ? <?php $auth = 1
$status = 1
if ( $result = (( $auth == 1 ) && ( $status != 0 ))) { print "result is $result"
} ?>
Correct Answer

(B) result is 1

Explanation

Solution: Result is x&&y which returns 1 if both x and y are true.