wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Introduction to PHP

Total questions: 15

Worksheet time: 16mins

Name
Class
Date
1.

PHP stands for ______________

a)

PHP:Hypermedia Preprocessor

b)

PHP:Hypertext Postprocessor

c)

PHP:Hypertext Preprocessor

d)

PHP:Hypermedia Postprocessor

2.

 Variable names in PHP begins with ________ sign.

a)

 $ 

b)

%

c)

#

d)

&

3.

In PHP string belongs to _________ datatype.

a)

Compound data

b)

scalar data

c)

special data

d)

unique data

4.

Array belongs to ________ data type in PHP.

a)

Compound data

b)

scalar data

c)

special data

d)

unique data

5.

What will be the output of the following PHP code? <?php $x = 23; echo ( $x ===23 );       ?>

a)

Displays “” (false)

b)

Displays 1 (true)

c)

 Displays 24

d)

Displays 23

6.

 In PHP the _____ loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true.

a)

for

b)

while

c)

do...while

d)

 foreach 

7.

What will be the output of the following PHP code? <?php $x = 2; $y = 3; echo ( ($x == 2) xor ($y == 3) );       ?>

a)

Displays (false)

b)

Displays 1 (true)

c)

 Displays 2

d)

Displays 3

8.

What type of language is PHP?

a)

Server side scripting

b)

Client side scripting

c)

User defined scripting

d)

None

9.

Choose the equivalent of the statement : $sub -= $sub.

a)

$sub=$sub-1;

b)

$sub=$sub-$sub;

c)

$sub=$sub

d)

$sub=$sub-$sub

10.

Total looping techniques supported by PHP are?

a)

3

b)

22

c)

4

d)

1

11.

<?php $x = 10; $y = 20; if ($x > $y && 1||1) echo "1000 PHP MCQ" ; else echo "Welcome to Sanfoundry"; ?>

a)

no output

b)

Welcome to Sanfoundry

c)

1000 PHP MCQ

d)

error

12.

Which of the following is used for concatenation in PHP?

a)

+ (plus)

b)

* (Asterisk)

c)

. (dot)

d)

append()

13.

<?php  

$a = 0;  

while ($a++)  

{  

echo "$a";  

}  

echo $a;  

?>  

a)

0

b)

1

c)

01

d)

none

14.

<?php  

$a = "1";  

switch($a)  

{  

case 1:  

echo "Hello";  

case 2:  

echo "World";  

default:  

echo "This is php.com";  

}  

?>  

a)

HelloWorld

b)

This is javaTpoint.com

c)

Hello

d)

HelloWorldThis is php.com

15.

<?php  

$a=0;  

if ($a)  

{  

echo "hi";  

}  

else  

{  

echo "How are you";  

}  

?>  

a)

Hi How are you

b)

How are you

c)

Hi

d)

None of the above