10 questions
---- statement executes a statement or a group of statements if a specific condition is satisfied as per the user expectation.
if...else
if
if..elseif..else
switch
Correct if syntax statement
(condition)
Execute statement(s) if condition is true;
if (condition):
{
Execute statement(s) if condition is true;
}
if (condition)
{
Execute statement(s) if condition is true;
}
if (con)
{
Execute statement(s) if condition is true;
}
------ statement executes a statement or a group of statements if a specific condition is satisfied by the user expectation. When the condition gets false (fail) the else block is executed.
if
if..else
if..elseif
switch
Correct syntax of if..else statement
else(condition)
{
Execute statement(s) if condition is true;
}
else
{
Execute statement(s) if condition is false;
}
if (condition)
{
Execute statement(s) if condition is true;
}
{
Execute statement(s) if condition is false;
}
if (condition)
{
Execute statement(s) if condition is true;
}
if (condition)
{
Execute statement(s) if condition is true;
}
else
{
Execute statement(s) if condition is false;
}
What will be the output of the following PHP code?
<?php
$a=5;
if($a>4)
print “Five” ;
else
print “Four”;
?>
Four
Five
three
two
------------------- statement is a combination of if-else
If-else-ifelse
If
If-else
If-elseif-else
-------statement is used to perform different actions based on different conditions.
if..else
if
switch
elseif
What will be the output of thefollowing PHP code ?
<?php
$x = 10;
$y = 20;
if ($x > $y )
print “hi” ;
else
print “how are u”;
?>
hi
how are u
hi how are u
Error
What will be the output of thefollowing PHP code?
<?php
$car = “skoda”;
switch ($car) {
case “skoda”:
echo “Your favorite car is skoda!”;
break;
case “BMW”:
echo “Your favorite car is BMW!”;
break;
default:
echo “Your favorite car neither skoda nor BMW!”;
}
Your favorite car is skoda!
Your favorite car is BMW!
Your favorite car neither skoda nor BMW!
Error
<?php
$a=35; $b=60; $c=70;
if ($a>= $b){
echo “A is big”;
}
elseif ($b>= $c){
echo “B is big”;
}
else {
echo “C is big”;
} ?>
A is big
Error
B is big
C is big