wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP QUIZ-2

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

What is the correct output of the given code <?php

$NUM1 = 3;

$NUM2 = 4;

$NUM3 = $NUM1 ** $NUM2;

echo $NUM3;

?>

a)

12

b)

81

c)

Garbage Value

d)

None of the above

2.

The "**" operator belongs to which category of operators?

a)

Arithmetic operator

b)

Logical operator

c)

Comparison operator

d)

Conditional operator

3.

Which of the following are comparison operators in PHP?

A. ==

B. !=

C. ===

D. < = >

a)

A and B

b)

C and D

c)

A,B and C

d)

A,B,C and D

4.

What is the Output:

<?php

$color= "red";

echo "$color";

echo "$COLOR";

echo "$Color";

?>

a)

redredred

b)

redred

c)

red

d)

Error

5.

What is the Output?

<?php

#echo "Hello World"

echo "#Hello World";

?>

a)

Hello World #Hello World

b)

Hello World

c)

#Hello World

d)

Error

6.

What is the Output


<?php

$color=red;

echo "$color";

?>

a)

red

b)

$color

c)

No answer

d)

Error

7.

What is the Ouput

<?php

$color1="green";

$color2="yellow";

echo "$color1" + "$color2";

?>

a)

greenyellow

b)

green yellow

c)

Error

d)

0

8.

What is the output?


<?php

define(GREETING, " PHP is a Scripting Language");

echo "$GREETING;

?>

a)

$GREETING

b)

no output

c)

GREETING

d)

PHP is a Scripting Language

9.

<?php

$x=10;

$y=4;

$z=3;

echo ($x % ($y) + $z);

?>

a)

5

b)

3

c)

0

d)

1

10.

What is the Output?

<?php

$four4 =4;

$three3 = 3;

$two2 = 2;

echo " $four4 + $three3 / $two2 - 1"

a)

4.5

b)

7

c)

3.5

d)

Error