wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP

Total questions: 100

Worksheet time: 50mins

Name
Class
Date
1.

Which tag is used for php

a)

<?php

?>

b)

<style>

c)

<php ?>

d)

<php

/php>

2.

What are the two types of array in php

a)

Indexed, sequence

b)

Associative, sequence

c)

Indexed, associative

d)

None

3.

$a=array("Timmy","Jimmy");

Is an example of

a)

Indexed array

b)

Associative array

c)

Sequence array

d)

None

4.

$a=array(10=>"Jimmy",20=>"mummy");

Is an example of

a)

Sequence array

b)

Indexed array

c)

Associative array

d)

None

5.

In php the keyword to be used before function name is

a)

Function

b)

Static

c)

function

d)

FUNCTION

6.

function add()

{

$a=10;

echo $a;}

This is an example for

a)

Call by value

b)

Call by reference

c)

None

d)

Both

7.

function add(&a)

{

$a=10;

echo $a;}

$a=33;

This is an example for

a)

Call by value

b)

Call by reference

c)

Both of the above

d)

None

8.

<?php

function add()

{

global $a=10;

echo $a;

}

add();

$a+=10;

?>

Output is

a)

10

b)

15

c)

20

d)

30

9.

$a="deepan";

$b="Deepan";

if(strcmp($a,$b))

{

echo "equal";

}

else{

echo " not equal";}

Output is

a)

Equal

b)

Not equal

c)

Error

d)

None

10.

$a="IT is favorite department";

$b=sub_string($a,"bes",7,14);

echo $b;

Output is

a)

IT is best department

b)

IT is bes department

c)

Error

d)

IT is favorite department

11.

HTML stands for

a)

Hyper Text Machine Language

b)

Hyper Text Markup Language

c)

Hyper Technical Machine Language

d)

None of these

12.

Choose the correct option About HTML elements

a)

Elements in HTML describes the way of presenting the content in the browser.

b)

All elements must have atleast one attribute associated with it.

c)

Element names are case in-sensitive

d)

None of the above

13.

Which one of the following is a form element?

a)

text box.

b)

radio button.

c)

submit button.

d)

All of these.

14.

Which one of the following is incorrect?

a)

<label> tag in HTML is used for creating a tag for form elements.

b)

id attribute is used with <label> to reduce the clickable area of form elements

c)

<label> can be used to increase the clickable area of buttons

d)

none of the above

15.

Choose the correct option.

a)

Default method in HTML is GET or POST

b)

Use of method attribute determines by which method the datas in the form will be submitted.

c)

Method can be POST or GET.

d)

Default method in HTML is GET.

16.

Which of the following tag is used for drop down list?

a)

<dropdown>

b)

<select>

c)

<option>

d)

<salect>

17.

Fill in the blanks with a suitable option in order to number items of an ordered list with small roman numbers.


<!DOCTYPE html>

<html>

<body>

<ol (a)   >

<li>

Physics

</li>

<li>

Chemistry

</li>

<li>

Mathematics

</li>

</ol>

</body>

</html>

18.

What is the default item marker in ordered lists of HTML?

a)

Circle

b)

Marker

c)

disc

d)

None of the above

19.

Which one of the following can be used to define the spacing between the cells of a table?

a)

border-spacing

b)

spacing

c)

cellspacing

d)

table-spacing

20.

How to insert a background image in HTML?

a)

<body background = "img.png">

b)

<img background = "img.png">

c)

<body style="background-image: url();">

d)

None of the above.

21.

Which HTML tag is used to display the power in expression, i.e., (x2 - y2)?

a)

<sub>

b)

<sup>

c)

<p>

d)

None of the above

22.
Choose PHP Conditional Operator from the list.
a)
?;
b)
:?
c)
??
d)
?/
23.
What is the output of the PHP code.?<br /><br /><?php<br /><br /> $a=0;<br /> $a = 5>2 ? print("4"): 3; <br /> print($a);<br />?>
a)
error
b)
14
c)
40
d)
41
24.

What is the output of the PHP code.

<?php

$a=0;

$a = 5>2 ?$b=6 : $b=8;

print("$a $a");?>

a)

6

b)

66

c)

68

d)

88

25.

What is the output of the PHP code.

<?php

if(4>5)

{print("Hurray..");}

print("yes");

?>

a)

Yes

b)

hurray..yes

c)

Hurray..Yes

d)

none of the above

26.

What is the output of the PHP code.

<?php

if(-5) {

print("Germany\n");

}


if(' ')


{ print("Texas\n"); }


printf("ZING");

?>

a)

ZING

b)

Germany ZING

c)

Germany Texas ZING

d)

error

27.
PHP Scripts starts with ________
a)
<php> … </php>
b)
<?php …. ?/>
c)
<?=........?>
d)
?php … ?php
28.

PHP is a____________side scripting language

a)

server

b)

browser

c)

client

29.

PHP stands for

a)

Hypertext processor

b)

Homepage processor

c)

Hypertext preprocessor

30.

Who is known as father of PHP

a)

Rasmus Lerdorf

b)

Brendan Eich

c)

Hakon Wium Lie

31.

Which of the following is not true?

a)

PHP can be used to develop web applications.

b)

PHP makes a website dynamic

c)

PHP can not be embedded into html.

32.

PHP scripts are enclosed within ___

a)

<php> . . . </php>

b)

<?php . . . ?>

c)

?php . . . ?php

33.

Variables used in php

a)

$a=5;

b)

var a=5;

c)

int a=5;

34.

_______ is a concatenation operator in php

a)

+ (plus)

b)

+=

c)

. (dot)

35.

Find the output

<?php

$x = 5;

{ $x = 10;

echo $x;

}

echo $x;

?>

a)

105

b)

510

c)

1010

36.

find the output

<?php

$x = 1;

$x += 1;


echo $x;

?>

a)

2

b)

1

c)

0

37.

Insert the missing part of the code below to output "Hello World".

a)

echo and print

b)

System.out.println

c)

println

d)

cout

38.

Write the correct opening tag and close tag for PHP scripts.

a)

{}

b)

<?php ?>

c)

<>

d)

<? ?>

39.

Statements in PHP have to end with a special character, which one?

a)

.

b)

,

c)

:

d)

;

40.

Create a variable in php assign with the

a)

String

b)

const

c)

let

d)

$

41.

Get the length of the string "Hello World!".

a)

Leng

b)

substring

c)

strlen

d)

len

42.

Use the correct function to output the number of items in an array.


$fruits = array("Apple", "Banana", "Orange");

a)

echo $fruits[0]

b)

echo $fruits["Apple"]

c)

echo count($fruits)

d)

echo $fruits[0][1]

43.

Write a correct syntax to include a file named "footer.php".

a)

include ("footer.php");

b)

import("footer.php");

c)

required("footer.php");

d)

export("footer.php");

44.

Assume we have a file named "webdict.txt", write the correct syntax to open and read the file content.

a)

readfile("webdict.txt")

b)

openfile("webdict.txt")

c)

writefile("webdict.txt")

d)

modifyfile("webdict.txt")

45.

Create a session variable named "favcolor".

a)

$session["favcolor"] = "green";

b)

$_SESSION["favcolor"] = "green";

c)

$_SESSION["favcolor"] ["green"];

d)

$SESSION["favcolor"] ="green";

46.

What type of language is PHP

a)

Client Side

b)

Server Side

c)

Browser Side

d)

Web Side

47.

PHP is executed on

a)

The Server

b)

The Browser

c)

The Website

d)

The Machine

48.

We create re-usable code blocks by placing them inside?

a)

Variables

b)

Parameters

c)

Code Blocks

d)

Functions

49.

Sometimes we only want certain code to execute if a condition is true. How do we test for that?

a)

Loop

b)

If Statement

c)

Integer

d)

Variable

50.

What is a String?

a)

Text

b)

Number

c)

True

d)

Loop

51.

What is a Boolean

a)

It's Just Text

b)

It's a Number

c)

It's Just True

d)

It's True or False

52.

What if we want a block of code to execute several times?

a)

Use a Variable

b)

Use a Function

c)

Use a Loop

d)

Use a Leap

53.

$colours = array("black, blue, Red, Green") - How do I access "Red" ?

a)

$colours[0];

b)

$colours[2];

c)

$colours[1]

d)

$colours[3];

54.

How do I print out the values of the variable "name" ?

a)

$name;

b)

include $name;

c)

echo $name;

d)

echo $name

55.

function sayMyName(name) {} ; - How do I call tat function

a)

sayMyname();

b)

$sayMyName;

c)

$sayMyName();

d)

sayMyName("John")';

56.

What does i++ do ?

a)

Adds the text on to the end of i

b)

Adds i on to the end of something

c)

Adds i on to the existing value of i

d)

Adds 1 to the current value of iThis is a correct answer

57.

In an IF statement we can have 2 conditions tested. Which keyword allows this?

a)

Else

b)

if Else

c)

Else if

d)

OR

58.

$a = "Ram"; $n = "Kumar"; $fullName = $f + $n; What is the value of $fulName

a)

RamKumar

b)

Ram Kumar

c)

Ram

d)

None

59.

$a = "Ram"; $n = "Kumar"; $fullName = $f . $n; What is the value of $fulName

a)

RamKumar

b)

Ram Kumar

c)

Kumar

d)

None

60.

function declarations can have (a)   assigned to them?

61.

PHP server scripts are surrounded by delimiters, which?

a)

<?php>...</?>

b)

<&>...</&>

c)

<script>...</script>

d)

<?php...?>

62.

What does PHP stand for?

a)

PHP: Hypertext Preprocessor

b)

Private Home Page

c)

Personal Hypertext Processor

63.

How do you write "Hello World" in PHP

a)

"Hello World";

b)

echo "Hello World";

c)

Document.Write("Hello World");

64.

All variables in PHP start with which symbol?

a)

!

b)

$

c)

&

65.

The PHP syntax is most similar to:

a)

JavaScript

b)

VBScript

c)

Perl and C

66.

How do you get information from a form that is submitted using the "get" method?

a)

Request.QueryString;

b)

Request.Form;

c)

$_GET[];

67.

When using the POST method, variables are displayed in the URL:

a)

True

b)

False

68.

In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:

a)

True

b)

False

69.

Include files must have the file extension ".inc"

a)

False

b)

True

70.

What is the correct way to include the file "time.inc" ?

a)

<?php include file="time.inc";?>

b)

<?php include "time.inc";?>

c)

<!-- include file="time.inc" -->

d)

<?php include:"time.inc";?>

71.

PHP allows you to send emails directly from a script

a)

False

b)

True

72.

What is the correct way to add 1 to the $count variable?

a)

$count++;

b)

count++;

c)

++count

d)

$count =+1

73.

What is a correct way to add a comment in PHP?

a)

<comment>...</comment>

b)

*\...\*

c)

/*...*/

d)

<!--...--->

74.

Which one of these variables has an illegal name?

a)

$my-Var

b)

$myVar

c)

$my_Var

75.

How do you create a cookie in PHP?

a)

setcookie()

b)

makecookie()

c)

createcookie()

76.

How do you create an array in PHP?

a)

$cars = array("Volvo","BMW","Toyota");

b)

$cars = "Volvo","BMW","Toyota";

c)

$cars = array["Volvo","BMW","Toyota"];

77.

The if statement is used to execute some code only if a specified condition is true

a)

True

b)

False

78.

Which operator is used to check if two values are equal and of same data type?

a)

=

b)

==

c)

===

d)

!=

79.

Which function is used to open a file

a)

fopen(filename, mode of opening file)

b)

fopen(file, mode of reading file)

c)

open(filename, mode of opening file)

d)

none

80.

if there is fopen function in program then there should always be

a)

fread()_

b)

fwrite()

c)

fclose()

d)

none

81.

!feof stands for

a)

file end of file

b)

not file end of file

c)

exlamatory file end of file

d)

none

82.

fread() reads contents of file

a)

word by word till eof

b)

paragraph by paragraph till end of file

c)

line by line till eof

d)

none

83.

When fwrite is used on already existing file the what will happen

a)

new contents added to previous file contents

b)

previous file contents deleted and new contents added

c)

error displayed

d)

none

84.

when you try to open a non existing file then

a)

error

b)

statement file not available

c)

question should i open new file in given name popped

d)

new file will be created in the given name

85.

Inorder to avoid conflicts what concept is used in files

a)

fblock()

b)

fclock()

c)

flock()

d)

none

86.

is block parameter in flock() optional

a)

true

b)

false

87.

Can values got from forms in html be given to php

a)

sometimes

b)

yes

c)

no

d)

none

88.

LOCK_EX stands for

a)

extended lock

b)

excess lock

c)

exclusive lock

d)

extrapolar lock

89.

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

90.

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

a)

Arithmetic operator

b)

Logical operator

c)

Comparison operator

d)

Conditional operator

91.

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

92.

What is the Output:

<?php

$color= "red";

echo "$color";

echo "$COLOR";

echo "$Color";

?>

a)

redredred

b)

redred

c)

red

d)

Error

93.

What is the Output:

<?php

$color= "red";

echo "$color";

echo "$COLOR";

echo "$Color";

?>

a)

redredred

b)

redred

c)

red

d)

Error

94.

What is the Output?

<?php

#echo "Hello World"

echo "#Hello World";

?>

a)

Hello World #Hello World

b)

Hello World

c)

#Hello World

d)

Error

95.

What is the Output


<?php

$color=red;

echo "$color";

?>

a)

red

b)

$color

c)

No answer

d)

Error

96.

What is the Ouput

<?php

$color1="green";

$color2="yellow";

echo "$color1" + "$color2";

?>

a)

greenyellow

b)

green yellow

c)

Error

d)

0

97.

<?php

$x=10;

$y=4;

$z=3;

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

?>

a)

5

b)

3

c)

0

d)

1

98.

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

99.

Which

of the following is a disadvantage of using JavaScript?

a)

Client-side

JavaScript does not allow the reading or writing of files.

b)

JavaScript

can not be used for Networking applications because there is no such support

available.

c)

JavaScript

doesn't have any multithreading or multiprocess capabilities.

d)

All of

the above.

100.

Which

of the following function of Array object extracts a section of an array and

returns a new array?

a)

reverse()

b)

shift()

c)

slice()

d)

some()