wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Server Side Scripting (PHP)

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.

What is PHP?

a)

A widely-used open source general-purpose scripting language.

b)

A type of database.

c)

A web server software.

d)

A programming language for mobile apps.

2.

What are the features of PHP?

a)

Easy to learn and runs efficiently.

b)

Requires complex setup.

c)

Not compatible with any server.

d)

Is a paid software.

3.

What does PHP stand for?

a)

Hypertext Preprocessor

b)

Personal Home Page

c)

Private Hypertext Page

d)

Public Hypertext Preprocessor

4.

What is the output of the following PHP code: echo 'Hello World!';

a)

Hello World!

b)

Hello World

c)

Hello

d)

World!

5.

What is the significance of the $ sign in PHP?

a)

It indicates a variable.

b)

It indicates a function.

c)

It indicates a constant.

d)

It indicates an array.

6.

What is the purpose of the echo statement in PHP?

a)

To output text to the screen.

b)

To declare a variable.

c)

To create a function.

d)

To include a file.

7.

What is the correct file extension for PHP files?

a)

.php

b)

.html

c)

.txt

d)

.xml

8.

What is a variable in PHP?

a)

A symbol that stands for a value.

b)

A type of function.

c)

A type of array.

d)

A type of database.

9.

What does it mean that PHP is a loosely typed language?

a)

Variables do not need to be declared with a data type.

b)

All variables must be declared with a data type.

c)

Variables can only hold one type of data.

d)

Variables must be declared before use.

10.

What must a variable name start with?

a)

A letter or underscore

b)

A number

c)

A special character

11.

What are the three different variable scopes in PHP?

a)

Local, global, static

b)

Public, private, protected

c)

Instance, class, static

12.

What does the var_dump() method do?

a)

Checks the data type of a variable

b)

Outputs the length of a string

c)

Counts the number of words in a string

13.

What is the syntax for a for loop in PHP?

a)

for(initialisation; condition; incrementation)

b)

for(condition; initialisation; incrementation)

c)

for(incrementation; condition; initialisation)

14.

What does the strlen() function do?

a)

Returns the length of a string

b)

Counts the number of words in a string

c)

Reverses a string

15.

What does the strrev() function do?

a)

Returns the length of a string

b)

Counts the number of words in a string

c)

Reverses a string

d)

Counts the reversed string

16.

What is an associative array in PHP?

a)

An array with named keys

b)

An array with numeric indices

c)

An array containing other arrays

17.

What is the syntax for declaring a user-defined function in PHP?

a)

function functionName() { code to be executed; }

b)

functionName() { code to be executed; }

c)

function functionName { code to be executed; }

d)

function functionName() { code executed; }

18.

What is the purpose of the return statement in a function?

a)

To end the function

b)

To return a value from the function

c)

To call another function

d)

To declare a variable

19.

What does the $_POST superglobal do?

a)

Collects form data sent via HTTP POST method

b)

Collects form data sent via URL parameters

c)

Stores session data

d)

Handles file uploads

20.

What is the difference between GET and POST methods?

a)

GET is visible in the URL, POST is not

b)

POST has limits on data size, GET does not

c)

GET is used for sensitive data, POST is not

d)

There is no difference

21.

What is the purpose of the PHP Data Object (PDO)?

a)

To connect PHP code with any database server.

b)

To create HTML pages.

c)

To manage user sessions.

d)

To store cookies.

22.

What does the isset() method do in PHP?

a)

Checks if a variable has a value.

b)

Creates a new variable.

c)

Deletes a variable.

d)

Displays a variable.

23.

What is a cookie in PHP?

a)

A small text file sent to the user's computer.

b)

A method to store user sessions.

c)

A type of database.

d)

A programming error.

24.

What is the purpose of sessions in PHP?

a)

To store user information on the server.

b)

To track user activities.

c)

To manage cookies.

d)

To connect to a database.

25.

What does the fetchAll() method do?

a)

Gets all records from a table.

b)

Inserts a new record into a table.

c)

Deletes a record from a table.

d)

Updates a record in a table.

26.

What is the correct way to create a database connection in PHP?

a)

$conn = new PDO($servername, $username, $password);

b)

$conn = new Database($servername, $username, $password);

c)

$conn = connect($servername, $username, $password);

d)

$conn = new Connection($servername, $username, $password);

27.

What is the purpose of the $_POST superglobal in PHP?

a)

To collect form data submitted via HTTP POST method.

b)

To collect URL parameters.

c)

To store session data.

d)

To manage cookies.

28.

What is the significance of the '->' operator in PDO?

a)

It is used to execute SQL statements.

b)

It is used to create a new PDO object.

c)

It is used to connect to a database.

d)

It is used to fetch records.

29.

What is the difference between GET and POST methods in PHP?

a)

GET has limits on the amount of information to send, while POST does not.

b)

POST is visible to everyone, while GET is not.

c)

GET is used for sensitive information, while POST is not.

d)

There is no difference.

30.

What does the mysqli_connect() function do?

a)

Establishes a connection to a MySQL database.

b)

Executes a SQL query.

c)

Fetches data from a database.

d)

Closes a database connection.