ExamVeda
Login
Home
11
What will be the output of the following PHP code ?
<?php
 $a = 5; $b = -7; $c =0; 
 $d = ++$a && ++$b || ++$c;
 print $d; print $a;
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
1&&0||1 is evaluated to 1 and the a is also preincremented to 6.
12
What will be the output of the following PHP code ?
<?php
$b = 1; $c = 4; $a = 5; 
$d = $b + $c == $a;
print $d;
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
First b and c are added and then tested if d=5,which is true thus return 1.
13
What will be the output of the following PHP code ?
<?php
echo 5 * 9 / 3 + 9;
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
Operator precedence order must be followed.
14
What will be the output of the following PHP code ?
<?php
$var1 = 1 + ++5;
echo $var1; 
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Operator ++ can be done only on variables.
15
What will be the output of the following PHP code ?
<?php
$var1 = 0;
$var1 = ($var1 + 5)++; 
echo $var1; 
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Operator ++ can be done only on variables.
16
What will be the output of the following PHP code ?
<?php
$var1 = 0;
$var1 = $var1++ + 5; 
echo $var1; 
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
Operator precedence followed.
17
What will be the output of the following PHP code ?
<?php
$var1 = 0;
$var1 = ++$var1 + 5; 
echo $var1; 
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
Operator precedence followed.
18
What will be the output of the following PHP code ?
<?php
$var1 = 0;
$var1 = $var1 + 5; 
echo $var1++; 
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
Operator precedence followed,incremented after display.
19
What will be the output of the following PHP code ?
<?php
$var1 = 1;
echo $var1 = ++$var1 % 2 + ++$var1; 
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
Evaluation done from right to left.
20
What will be the output of the following PHP code ?
<?php
$var1 = 1;
echo $var1 = ++$var1 % 2 + ++$var1; 
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
Evaluation done from right to left.