PHP If Else/Else If Statement
- What will be the output of the following PHP code ?
<?php
$num = 5;
if ($num = $num&0)
print $num ;
else
print "Else statement executed...";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
num&0 is 0,thus evaluated to false.
- What will be the output of the following PHP code ?
<?php
$p = 20;
if ($p = $p&0)
print $p ;
else
print "Executed...";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
p&0 is 0,thus evaluated to false.
- What will be the output of the following PHP code ?
<?php
$t = 11;
if ($t = $t&0)
print $t;
else
break;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
break is not defined for a if else ladder.
- What will be the output of the following PHP code ?
<?php
$p = 150;
if ($p > 25)
printf("Ajit");
else if ($p > 35)
printf("Ats");
else if($p > 45)
printf("Aju");
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In if else if one condition is satisfied then no other condition is checked.
- What will be the output of the following PHP code ?
<?php
$p = 25;
$q = 50;
$r = 15;
if ($p / $q / $r)
print "Interview";
else
print "Mania";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In php division returns a float that is a non zero value thus evaluates to true.