ExamVeda
Login
Home
21
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 pre incremented to 6.
22
What will be the output of the following PHP code ?
<?php
$var1 = 3;
print $var = ++$var;
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
$var = ++$var returns 1(success).
23
What will be the output of the following PHP code ?
<?php
$var1 = 3;
print ++$var++;
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
First preincrement is done and the result is a number,thus post increment cannot be performed on it.
24
What will be the output of the following PHP code ?
<?php
$i = 0; $j = 1; $k = 2;
print !(($i + $k) < ($j - $k));
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
True is 1.
25
What will be the output of the following PHP code ?
<?php
$i = 0;$j = 1;$k = 2;
print !(( +  + $i + $j) > ($j - $k));
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
The equation outputs false .
26
What will be the output of the following PHP code ?
<?php
$i = 0;$j = 1;$k = 2;
print (( +  + $i + $j) >! ($j - $k));
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
Negation of a number is 0.
27
What will be the output of the following PHP code ?
<?php
$a = 0x6db7;
print $a<<6;
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
The output is in decimal.
28
What will be the output of the following PHP code ?
<?php
$a  =  'a' ;
print $a * 2;
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
Characters cannot be multiplied.
29
What will be the output of the following PHP code ?
<?php
$a  =  '4' ;
print  +  + $a;
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
The character is type casted to integer before multiplying.
30
What will be the output of the following PHP code ?
<?php
$a  =  '12345';
print "qwe{$a}rty";
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
{$}dereferences the variable within.