wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz-4: Function & Array

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is the correct way to declare an array in PHP?

a)

array()

b)

array[]

c)

array{}

d)

array<>

2.

What is the output of the following code? $fruits = array('apple', 'banana', 'orange'); echo $fruits[1];

a)

orange

b)

banana

c)

apple

d)

grape

3.

What is the output of the following code? $numbers = array(1, 2, 3, 4, 5); echo count($numbers);

a)

3

b)

2

c)

5

d)

1

4.

Which function is used to remove the last element from an array in PHP?

a)

array_push()

b)

array_shift()

c)

array_slice()

d)

array_pop()

5.

Which function is used to sort an array in ascending order in PHP?

a)

sort

b)

ksort

c)

asort

d)

rsort

6.

How to define a function in PHP?

a)

function {function body}

b)

data type functionName(parameters) {function body}

c)

functionName(parameters) {function body}

d)

function functionName(parameters) {function body}

7.

Total looping techniques supported by PHP are?

a)

1

b)

2

c)

3

d)

4

8.

Choose whether true or false: the do-while loop is an exit control loop.

a)

True

b)

False

c)

Depends on the condition

d)

None of these

9.

Functions in PHP should start with which of the following keyword?

a)

function

b)

fun

c)

def

d)

None of these

10.

Total types of the array in PHP is?

a)

1

b)

2

c)

3

d)

4

11.

Index of an array by default starts with which of the following in PHP?

a)

-1

b)

0

c)

1

d)

2

12.

Another term used for Objects is?

a)

class

b)

instance

c)

reference

d)

None of these

13.


Using which keyword is the object created?

a)

class

b)

new

c)

def

d)

None of these

14.

Total error levels available in PHP are?

a)

15

b)

16

c)

17

d)

18

15.

Find the output of the code below:

<?PHP

ECHO CHR(52);

?>

a)

1

b)

2

c)

3

d)

4