ExamVeda
Login
Home
11
What will be the output of the following PHP code ?
<?php
$a = "a";
if ($a) 
    print "all";
else 
    print "some";
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
The value of a is evaluated to 1 as it has a value.
12
What will be the output of the following PHP code ?
<?php
$x = 10;
$y = 20;
if ($x > $y + $y != 3)
    print "hi" ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Expression evaluates to true.
13
What will be the output of the following PHP code ?
<?php
$x = 10;
$y = 20;
if ($x > $y && 1||1)
    print "hi" ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Expression evaluates to true.
14
What will be the output of the following PHP code ?
<?php
$x = 10;
$y = 20;
if ($x > $y && 1||1)
    print "hi" ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Expression evaluates to true.
15
What will be the output of the following PHP code ?
<?php
if (-100)
    print "hi" ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
16
What will be the output of the following PHP code ?
<?php
if (0.1)
    print "hi" ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Expression evaluates to true.
17
What will be the output of the following PHP code ?
<?php
if (0.0)
    print "hi" ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
Expression evaluates to false.
18
What will be the output of the following PHP code ?
<?php
if (print "0")
    print "hi" ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Expression evaluates to true as print returns 1.
19
What will be the output of the following PHP code ?
<?php
$x = 1;
if ($x == 2)
    print "hi" ;
else if($x = 2)
    print $x;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Enters if else as first condition is false and thus x is set to 2.
20
What will be the output of the following PHP code ?
<?php
$x = 1;
if ($x = $x& 0)
    print $x ;
else
    print "how are u";
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
x&0 is 0,thus evaluated to false.