Operators And Expressions In Php - Study Mode
[#131] What will be the output of the following PHP code ? <?php $on_e = 1
$tw_o = 2
$thre_e = 3
$fou_r = 4
echo $on_e / $tw_o + $thre_e / $fou_r
?>
Correct Answer
(C) 1.25
(E) 0.75
Explanation
Solution: You can use _ in a variable name.
[#132] What will be the output of the following PHP code ? <?php $On_e = 1
$tw_o = 2
$thre_e = 3
$fou_r = 4
echo $on_e / $tw_o + $thre_e / $fou_r
?>
Correct Answer
(C) 1.25
(E) 0.75
Explanation
Solution: Since the variable initialised is $On_e and the variable in the echo statement is $on_e the echo statement treats $on_e as 0
[#133] What will be the output of the following PHP code ? <?php echo $red
?>
Correct Answer
(B) Nothing
Explanation
Solution: There will no output returned as the variable $red does not hold any value.
[#134] What will be the output of the following PHP code ? <?php $four4 = 4
$three3 = 3
$two2 = 2
echo $four4 + $three3 / $two2 - 1
?>
Correct Answer
(A) 4.5
Explanation
Solution: You can use numbers in a variable name.
[#135] What will be the output of the following PHP code ? <?php $4four = 4
$3three = 3
$2two = 2
echo $4four + $3three / $2two - 1
?>
Correct Answer
(D) Error
Explanation
Solution: A variable name can not start with a numeric value.