PHP If Else/Else If Statement
- What will be the output of the following PHP code ?
<?php
$num = "";
if ($num)
print "Second";
else
print "First";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Empty string is evaluated to 0.
- What will be the output of the following PHP code ?
<?php
$n1 = 17;
$n2 = 19;
if ($n1 > $n2 + $n2 != 3)
print "Interview" ;
else
print "Mania";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Expression evaluates to true.
- What will be the output of the following PHP code ?
<?php
$str = "s";
if ($str)
print "Executed....";
else
print "Not Executed...";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The value of str is evaluated to 1 as it has a value.
- What will be the output of the following PHP code ?
<?php
$num1 = 25;
$num2 = 27;
if ($num1 > $num2 && 1||1)
print "Manjesh" ;
else
print "Ojha";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Expression evaluates to true.
- What will be the output of the following PHP code ?
<?php
$num = 5;
if (5)
print "First";
if
else
print "Second";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
No else statement to end the if statement.