#### PHP Conditional Statements Model Question Paper

12th Standard

Reg.No. :
•
•
•
•
•
•

Computer Applications

Time : 02:00:00 Hrs
Total Marks : 50
5 x 1 = 5
1. What will be the output of the following PHP code?
< ? php
 x;
if (x)
print “hi” ;
else
print “how are u”;
? >

(a)

how are u

(b)

hi

(c)

error

(d)

no output

2. Statement which is used to make choice between two options and only option is to be performed is written as

(a)

if statement

(b)

if else statement

(c)

then else statement

(d)

else one statement

3. What will be the output of the following PHP code ?
< ?php
a = “”;
if (a)
print “all”;
if
else
print “some”;
? >

(a)

all

(b)

some

(c)

error

(d)

no output

4. 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”;
? >

(a)

how are u

(b)

hi

(c)

error

(d)

no output

5. What will be the output of the following PHP code ?
< ?php
if (-100)
print “hi” ;
else
print “how are u”;
? >

(a)

how are u

(b)

hi

(c)

error

(d)

no output

6. 3 x 1 = 3
7. What will be the output of the following
PHP co e?
< ?php
if(0.1)
print''hi'';
else
print''how are u";
? >
a) how are u
b) hi
c) error
d) no output

8. What will be the output of the following
PHPcode?
< ?php
＄x=l;
if(＄x==2)
print''hi'';
elseif(＄x=2)
print\$x;
else
print''how are u";
? >
a) error
b) 2
c) hi
d) how are u

9. Wh t will be the output of the following
P ode?
< ?php
＄a="l";
switch(＄a)
{
casel:
break;
print''hi'';
case2:
print''hello'';
break;
default:
print''hi1'';
}
? >
a) hihellohi1
b) hi
c) hihi1
d) hi1

10. 6 x 2 = 12
11. Define Conditional Statements in PHP

12. What is if else statement in PHP?

13. Write the Syntax of the If else statement in PHP.

14. Write the usage of Switch Statement in PHP.

15. Write the Syntax of Switch statement.

16. Compare if and if else statement.

17. 5 x 3 = 15
18. Write the features Conditional Statements in PHP.

19. Differentiate Switch and if else statement

20. Differentiate if statement and if else if else stament.

21. Write a PHP code to display "Have a nice weekend!" if the current day is Friday, otherwise it will output "Have a nice day!" using if-else statement.

22. Write, a PHP program to display independenc day and republic day the greetings using If elseif else statement.

23. 3 x 5 = 15
24. Explain the Function of Conditional Statements in PHP.

25. Explain if else statement in PHP. With an example.