Operators And Expressions In Php - Study Mode
[#71] What will be the output of the following PHP code ? <?php echo "This" , "was" | "a" , "bad" . "idea"
?>
Correct Answer
(B) Thiswasbadidea
Explanation
Solution: You can use only comma and dot operator to join starings, other characters do not have the same function.
[#72] What will be the output of the following PHP code ? <?php $i = 2
while (++ $i ) { while ( $i --> 0 ) print $i
} ?>
Correct Answer
(A) 210
Explanation
Solution: The loop ends when i becomes 0.
[#73] What will be the output of the following PHP code ? <?php $i = 2
while (++ $i ) { while (-- $i > 0 ) print $i
} ?>
Correct Answer
(D) infinite loop
Explanation
Solution: The loop never ends as i is always incremented and then decremented.
[#74] What will be the output of the following PHP code ? <?php echo 5 * 9 / 3 + 9
?>
Correct Answer
(A) 24
(E) 24
Explanation
Solution: Operator precedence order must be followed.
[#75] What will be the output of the following PHP code ? <?php $i = 0
$j = 0
if ( $i && ( $j = $i + 10 )) { echo "true"
} echo $j
?>
Correct Answer
(B) 0
Explanation
Solution: In if condition when the first case is 0 and is an && operation then the second command is not executed.