wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP FUNDAMENTALS

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

    What is PHP?

a)

PHP is an open-source programming language

b)

PHP is used to develop dynamic and interactive websites

c)

PHP is a server-side scripting language

d)

All of the mentioned

2.

What does PHP stand for?

a)

PHP stands for Preprocessor Home Page

b)

PHP stands for Pretext Hypertext Processor

c)

PHP stands for Hypertext Preprocessor

d)

PHP stands for Personal Hyper Processor

3.

Which of the following is the correct way to add a comment in PHP code?

a)

#

b)

//

c)

/* */

d)

All of the mentioned

4.

     Which of the following is the default file extension of PHP files?

a)

.php

b)

.ph

c)

.xml

d)

.html

5.

      How to define a function in PHP?

a)

functionName(parameters) {function body}

b)

function {function body}

c)

function functionName(parameters) {function body}

d)

data type functionName(parameters) {function body}

6.
a)

$GREETING

b)

no output

c)

PHP is a scripting language

d)

 GREETING

7.

What will be the value of the variable $input in the following PHP program?

<?php

$input = "PHP<td>stands for</td>Hypertext<i>Preprocessor</i>!";

$input = strip_tags($input,"<i></i>");

echo $input;

?>

a)

PHP stands for Hypertext <i>Preprocessor</i>!

b)

PHP stands for Hypertext Preprocessor!

c)

PHP <td>stands for</td> Hypertext <i>Preprocessor</i>!

d)

PHP <td>stands for</td> Hypertext Preprocessor!

8.

 What will be the output of the following PHP program?

 

<?php

$a = 100;

if ($a > 10)

    printf("PHP Quiz");

else if ($a > 20)

    printf("PHP MCQ");

else if($a > 30)

    printf("PHP Program");

?>

(a)  

9.

Which of the looping statements is/are supported by PHP?

i) for loop

ii) while loop

iii) do-while loop

iv) foreach loop

a)

Only iv

b)

i) and ii)

c)

i), ii) and iii)

d)

i), ii), iii) and iv)

10.

Which PHP statement will give output as $x on the screen?

a)

echo “\$x”;

b)

echo “$$x”;

c)

echo “/$x”;

d)

echo “$x;”;

11.

What will be the output of the following PHP code?

<?php

$x = 4;

$y = 3

$z = 1;

$z = $z + $x + $y;

echo "$z";

?>

(a)  

12.

What will be the output of the following PHP program?

 

<?php

$mcq = (a)   ;

switch(print $mcq)

{

case 2:

    print "HTML";

    break;

case 1:

    print "CSS";

    break;

default:

    print "JavaScript";

}

?>

13.

Which variable is used to collect form data sent with both the GET and POST methods?

a)

$_BOTH

b)

$REQUEST

c)

$_REQUEST

d)

$BOTH

14.

Variable name in PHP starts with -

a)

! (Exclamation)

b)

$ (Dollar)

c)

&(Ampersand)

d)

#(Hash)

15.

Which of the following is used to display the output in PHP?

a)

echo

b)

write

c)

print

d)

Both (a) and (c)

16.

1.      Which of the following is the use of strlen() function in PHP?

a)

The strlen() function returns the type of string

b)

The strlen() function returns the length of string

c)

The strlen() function returns the value of string

d)

The strlen() function returns both value and type of string

17.

  Which of the following is used for concatenation in PHP?

a)

+ (plus)

b)

* (Asterisk)

c)

. (dot)

d)

append()

18.

Which of the following is the use of strpos() function in PHP?

a)

The strpos() function is used to search for the spaces in a string

b)

The strpos() function is used to search for a number in a string

c)

The strpos() function is used to search for a character/text in a string

d)

The strpos() function is used to search for a capitalize character in a string

19.

Which of the following is the correct way to create a function in PHP?

a)

Create myFunction()

b)

New_function myFunction()

c)

function myFunction()

d)

None of the above

20.

Syntax for declaring a variable is (a)  

21.

Which of the following is/are the code editors in PHP?

a)

Notepad++

b)

Notepad

c)

Adobe Dreamweaver

d)

All of the above

22.

Which of the following is used to end a statement in PHP?

(a)  

23.

String values in PHP must be enclosed within -

a)

Double Quotes

b)

Single Quotes

c)

Both (a) and (b)

d)

None of the above

24.

Which of the following variable name is invalid?

a)

$newVar

b)

$new_Var

c)

$new-var

d)

All of the above

25.

Which of the following is the correct way to print "Hello World" in PHP?

a)

"Hello World";

b)

write("Hello World");

c)

echo "Hello World";

d)

None of the above

26.

Which of the following function converts a string to all uppercase?

a)

upper()

b)

uppercase()

c)

struppercase()

d)

strtoupper()

27.

What will be the output of the following program?

 

<?php 

echo "Welcome" . "to" . "the" . "javaTpoint.com"; 

?> 

a)

Welcome to the javaTpoint.com

b)

Welcome, to, the, javaTpoint.com

d)

Error

28.

What will be the output of the following program?

 

<?php 

echo "Welcome" , "to" , "the" , "javaTpoint.com"; 

?> 

a)

Welcome to the javaTpoint.com

b)

Welcome, to, the, javaTpoint.com

d)

Error

29.

   What will be the output of the following program?

 

<?php 

$var1 = "Hello"; 

$var2 = "World"; 

echo $var1, $var2; 

?> 

(a)  

30.

   What will be the output of the following program?

 

<?php 

$var1 = "Hello"; 

$var2 = "World"; 

echo "$var1$var2"; 

?> 

a)

HelloWorld

b)

"$var1$var2"

c)

Hello World

d)

None of the above

31.

What will be the output of the following program?

 

<?php 

$a; 

if ($a) 

echo "hi"; 

else 

echo "How are you"; 

?> 

(a)  

32.

What will be the output of the following program?

 

<?php 

$a = 0; 

while ($a++) 

echo "$a"; 

echo $a; 

?> 

a)

0

b)

1

c)

01

d)

none of the above

33.

What will be the output of the following program?

 

<?php 

echo (a)   ;

?> 

34.

What will be the output of the following program?

 

<?php 

$a = _____; 

function show() 

$a = _____; 

echo "$a"; 

show(); 

echo "$a"; 

?> 

(a)  

35.

What will be the output of the following program?

<?php   

  $var1="Hello World";   

  echo strrev("$var1");    

?>    

(a)  

36.

Which of the following is correct about PHP?

a)

PHP is a recursive acronym for "PHP: Hypertext Preprocessor".

b)

 PHP is a server side scripting language that is embedded in HTML.

c)

It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.

d)

All the above

37.

   Which of the following is correct about constants vs variables in PHP?

a)

Constants may be defined and accessed anywhere without regard to variable scoping rules.

b)

Once the Constants have been set, may not be redefined or undefined.

c)

Both of the above.

d)

None of the above.

38.

Which of the following function is used to get length of a string?

(a)  

39.

PHP is an example of ---------------scripting language

(a)  

40.

Which of the following is not true?

a)

PHP can be used to develop web applications.

b)

PHP makes a website dynamic

c)

PHP applications can not be compile

d)

 PHP can not be embedded into html