Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Learn PHP Basics

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What does PHP stand for?

a)

Private Hypertext Protocol

b)

Personal Home Page

c)

PHP: Programming Hypertext

d)

PHP: Hypertext Preprocessor

2.

How do you declare a variable in PHP?

a)

variable name

b)

$variableName

c)

variableName$

d)

#variableName

3.

What symbol is used to start a comment in PHP?

a)

#

b)

/*

d)

//

4.

What is the purpose of an if statement in PHP?

a)

To define a function in PHP.

b)

The purpose of an if statement in PHP is to execute code conditionally based on a boolean expression.

c)

To create a loop in PHP.

d)

To declare a variable in PHP.

5.

How do you define a function in PHP?

a)

A function in PHP is defined using the syntax: function functionName(parameters) { // code }.

b)

To define a function in PHP, use the syntax: functionName(parameters) => { // code }.

c)

A function in PHP is defined with the syntax: define functionName(parameters) { // code }.

d)

Functions in PHP are created using the syntax: func functionName(parameters) { // code }.

6.

What is an array in PHP?

a)

An array in PHP is a single value container.

b)

An array in PHP can only hold string values.

c)

An array in PHP is a data structure that holds multiple values, which can be indexed numerically or associatively.

d)

An array in PHP is a type of function.

7.

How can you access the first element of an array?

a)

Use arrayName[0] to access the first element of an array.

b)

Access the first element with arrayName.first() method.

c)

The first element can be retrieved using arrayName.get(0).

d)

Use arrayName[1] to access the first element of an array.

8.

How do you include a PHP file in an HTML document?

a)

Include the PHP file in a CSS file instead.

b)

Use or within the HTML document.

c)

Add filename.php directly in the HTML body without PHP tags.

d)

Use in the HTML document.

9.

What is the difference between echo and print in PHP?

a)

The main difference is that 'echo' can take multiple parameters and does not return a value, while 'print' takes one argument and returns 1.

b)

Both 'echo' and 'print' are identical in functionality.

c)

'print' can take multiple parameters and does not return a value.

d)

'echo' returns a value while 'print' does not.

10.

How do you create a loop in PHP?

a)

Loops in PHP can only be created with 'switch' cases.

b)

You can create a loop in PHP using 'if' statements.

c)

You must use 'print' to create a loop in PHP.

d)

You can create a loop in PHP using 'for', 'while', or 'foreach' constructs.