wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PHP Initial Evaluation

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What type of language is PHP

a)

Client Side

b)

Server Side

c)

Browser Side

d)

Web Side

2.

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

a)

$colours[0];

b)

$colours[2];

c)

$colours[1]

d)

$colours[3];

3.

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

a)

$name;

b)

include $name;

c)

echo $name;

d)

echo $name

4.

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

a)

sayMyname();

b)

$sayMyName;

c)

$sayMyName();

d)

sayMyName("John");

5.

$a = 4 ; $b = 6; $c = $a + $b; What is the value of variable "c" ?

a)

6

b)

8

c)

10

d)

None

6.

PHP scripts are enclosed within ___

a)

<php> . . . </php>

b)

<?php . . . ?>

c)

?php . . . ?php

7.

Find the output

<?php

$x = 5;

{ $x = 10;

echo $x;

}

echo $x;

?>

a)

105

b)

510

c)

1010

8.

find the output

<?php

$x = 1;

$x += 1;


echo $x;

?>

a)

2

b)

1

c)

0

9.

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");

10.

Create a session variable named "favcolor".

a)

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

b)

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

c)

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

d)

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

11.

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

a)

Request.QueryString;

b)

Request.Form;

c)

$_GET[];

12.

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

a)

True

b)

False

13.

What is the correct way to create a function in PHP?

a)

new_function myFunction()

b)

function myFunction()

c)

create myFunction()

14.

Which superglobal variable holds information about headers, paths, and script locations?

a)

$_GET

b)

$_SESSION

c)

$_SERVER

d)

$GLOBALS

15.

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

a)

<comment>...</comment>

b)

*\...\*

c)

/*...*/

d)

<!--...--->

16.

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"];

17.

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

a)

=

b)

==

c)

===

d)

!=

18.

Which of the following is the correct way of defining a variable in PHP?

a)

$variable name = value;

b)

$variable_name = value;

c)

$variable_name = value

d)

$variable name as value;

19.

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

a)

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

b)

The strlen() function returns the length of string

c)

The strlen() function returns the type of string

d)

The strlen() function returns the value of string

20.

When concatenating strings, you use what symbol in PHP?

a)

A comma ,

b)

A plus sign +

c)

a hyphen -

d)

a full stop .