wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP Quiz

Total questions: 69

Worksheet time: 40mins

Name
Class
Date
1.

Who developed PHP?

a)

Linus Torvalds

b)

James Gosling

c)

Rasmus Lerdorf

d)

Guido van Rossum

2.

In which year was PHP developed?

a)

1984

b)

1994

c)

2004

d)

2014

3.

What is PHP primarily used for?

a)

Mobile applications

b)

Server-side scripting

c)

Desktop software

d)

Operating systems

4.

PHP is embedded in which type of pages?

a)

HTML

b)

XHTML

c)

XML

d)

JSON

5.

What does PHP stand for?

a)

Personal Home Page

b)

PHP Hypertext Preprocessor

c)

Preprocessed HTML Pages

d)

Programmable Hyperlinking Protocol

6.

Which of the following is a feature of PHP?

a)

Poor support for form processing

b)

Limited to MySQL databases

c)

Good support for form processing

d)

Cannot interface with databases

7.

PHP can interface with a wide variety of databases.

a)

True

b)

False

8.

What are the two ways to create dynamic behavior in web applications?

a)

Server-side scripting code and client-side scripting code

b)

HTML and CSS

c)

Static files and databases

d)

XML and JSON

9.

Which scripting code is executed on the server side?

a)

JavaScript

b)

PHP

c)

HTML

d)

CSS

10.

Which scripting code is executed on the client side?

a)

PHP

b)

XML

c)

JavaScript

d)

Server-side scripting code

11.

What is one of the advantages of server-side programming in terms of security?

a)

Server-side code is visible to the client

b)

Server-side code has access to the server's important and/or private data

c)

Server-side code is slower to access

d)

Server-side code can be modified by the client

12.

How does server-side programming contribute to compatibility?

a)

It requires users to update their browsers more frequently

b)

It increases browser JavaScript compatibility issues

c)

It avoids browser JavaScript compatibility issues

d)

It has no effect on browser compatibility

13.

What is an efficiency benefit of server-side programming?

a)

Users have to run a script to view each page

b)

Users have to send the entire data set from server to user's browser

c)

It's slower for users

d)

Users don't have to run a script to view each page

14.

Which of the following is a power advantage of server-side programming?

a)

There are more restrictions on what the server can do

b)

It cannot open connections to other servers

c)

It can write to files, open connections to other servers, connect to databases, etc.

d)

It is limited to the capabilities of the client's browser

15.

What happens when a PHP document is requested from a server?

a)

The server sends the PHP document directly to the client.

b)

The server processes the PHP document and sends an HTML page to the client.

c)

The client processes the PHP document and sends it back to the server.

d)

The PHP document is deleted from the server after the request.

16.

What is the role of the server in the execution of a PHP file?

a)

The server requests the PHP file from the client.

b)

The server sends the PHP file to another server for processing.

c)

The server executes the PHP file and creates a response HTML file.

d)

The server stores the PHP file without executing it.

17.

How many modes of operation does the PHP processor have?

a)

One

b)

Two

c)

Three

d)

Four

18.

What happens in the copy mode of PHP processor operation?

a)

PHP code is executed and the result is sent to the output file

b)

PHP code is interpreted and the output from that code is sent to the output file

c)

Plain HTML in the input file is copied to the output file

d)

The output file is sent directly to the client without processing

19.

What is required of the output of a PHP script in interpret mode?

4 lines
20.

Who sees the output produced by the PHP code?

a)

The PHP processor

b)

The server administrator

c)

The client (i.e., the user)

d)

The web developer

21.

Which of the following is a characteristic of PHP?

a)

Static typing

b)

Typed variables

c)

Associative arrays

d)

Lack of libraries

22.

PHP is known for having:

a)

Limited pattern matching capabilities

b)

No libraries available

c)

Extensive libraries

d)

Inflexible array structures

23.

PHP code is contained between which tags?

a)

and

b)

c)

d)

24.

How can code be included in a PHP file?

a)

include("table2.inc");

b)

require("table2.inc");

c)

insert("table2.inc");

d)

append("table2.inc");

25.

What happens when a file is included in PHP?

a)

The PHP interpreter stops

b)

The PHP interpreter reverts to copy mode

c)

The PHP interpreter executes the file immediately

d)

The PHP interpreter ignores the file

26.

PHP code in an included file must also be enclosed in which tags?

a)

and

b)

c)

d)

27.

What is the correct way to start a PHP scripting block?

a)

b)

c)

BEGIN PHP your PHP code END PHP

d)

[PHP] your PHP code [/PHP]

28.

What does a simple PHP program that outputs "Hello World" to the browser indicate?

a)

The PHP installation is incorrect.

b)

The PHP script is configured to send data to the server.

c)

The PHP script can send output to the browser window.

d)

The PHP script is an example of a complex program.

29.

Which two basic output statements are used in PHP?

a)

include and require

b)

if and else

c)

print and echo

d)

for and while

30.

What do the print and echo functions in PHP take as parameters?

a)

Array parameters

b)

String parameters

c)

Integer parameters

d)

Object parameters

31.

Can you optionally surround strings in PHP with parentheses when using echo or print?

a)

Yes, you can optionally use parentheses.

b)

No, you cannot use parentheses at all.

c)

Only with the echo function.

d)

Only with the print function.

32.

What is the purpose of the print and echo functions in PHP?

a)

To define variables

b)

To create functions

c)

To send data to output

d)

To perform arithmetic operations

33.

PHP statements are terminated with what symbol?

a)

A period (.)

b)

A comma (,)

c)

A semicolon (;)

d)

A colon (:)

34.

What is used to create compound statements in PHP?

a)

Parentheses

b)

Square brackets

c)

Angle brackets

d)

Curly braces

35.

How can single line comments be started in PHP?

4 lines
36.

Multi-line comments in PHP begin with which symbols?

a)

'//'

b)

''

c)

'/*' and end with '*/'

d)

'#'

37.

What symbol do all variable names in PHP begin with?

a)

#

b)

@

c)

$

d)

%

38.

Are variable names in PHP case sensitive?

a)

Yes

b)

No

c)

Only when used inside functions

d)

Only when used outside functions

39.

Are keywords and function names in PHP case sensitive?

a)

Yes

b)

No

c)

Only keywords are case sensitive

d)

Only function names are case sensitive

40.

How are variables in PHP declared?

a)

With a specific declare statement

b)

Implicitly by assignment

c)

By using the var keyword

d)

With a specific type declaration

41.

Do PHP variables require a type to be specified when they are declared?

a)

Yes, always

b)

No, never

c)

Only for global variables

d)

Only for local variables

42.

How many scalar data types are mentioned in the document?

a)

Two

b)

Three

c)

Four

d)

Five

43.

Which of the following is a function used to test the type of a variable in PHP?

a)

test_type

b)

get_type

c)

is_type

d)

is_string

44.

What type of auto-conversion does PHP perform when a string is used with a plus (+) operator?

a)

string to boolean

b)

string to array

c)

string to integer

d)

string to object

45.

Which of the following is an example of type-casting in PHP?

a)

$age = "21"

b)

$age = 21

c)

$age = (int)"21"

d)

$age = (string)21

46.

PHP distinguishes between which two types of numeric types?

a)

Integer and String

b)

Floating point and Double

c)

Integer and Floating point

d)

Boolean and Integer

47.

In PHP, an integer is usually equivalent to what data type in C?

a)

char

b)

int

c)

long

d)

short

48.

What can double literals include in PHP?

a)

Only decimal point

b)

Only exponent

c)

Decimal point or exponent

d)

Neither decimal point nor exponent

49.

String literals in programming are enclosed in what?

a)

Parentheses

b)

Single or double quotes

c)

Brackets

d)

Curly braces

50.

What is true about double-quoted strings?

a)

They cannot contain variables

b)

They interpret escape sequences and variables are interpolated

c)

They do not interpret escape sequences

d)

They cannot span multiple lines

51.

How is a literal $ sign represented in a double-quoted string?

a)

Using a single quote

b)

Preceding it with a backslash, \

c)

By doubling the $ sign

d)

It does not need to be escaped

52.

Can double-quoted strings cover multiple lines in programming?

a)

No, they are limited to a single line

b)

Yes, but they cannot include end of line characters

c)

Yes, and the included end of line characters are part of the string value

d)

Yes, but only if concatenated with a plus sign

53.

Which of the following is true about single-quoted strings?

a)

They interpret escape sequences and variables are interpolated

b)

They can span multiple lines without including end of line characters

c)

They have neither escape sequence interpretation nor variable interpolation

d)

A literal $ sign does not need to be escaped

54.

In PHP, what is the output of the statement 'print "You are $age years old.\n";' if the variable $age is set to 16?

a)

You are $age years old.

b)

You are 16 years old.

c)

You are .16. years old.

d)

You are ${age} years old.

55.

Which of the following statements correctly describes the use of single quotes and double quotes in PHP?

a)

Variables inside single quotes are not expanded.

b)

Variables inside double quotes are not expanded.

c)

Both single and double quotes expand variables within strings.

d)

Neither single nor double quotes can be used to enclose variable names within strings.

56.

How is string concatenation indicated in PHP?

a)

With a comma (,)

b)

With a plus sign (+)

c)

With a period (.)

d)

With a semicolon (;)

57.

How are characters accessed in a string in PHP?

a)

Using square brackets []

b)

Using parentheses ()

c)

Using curly braces {}

d)

Using angle brackets <>

58.

What does the PHP function strlen do?

a)

Removes whitespace from the end of a string

b)

Compares two strings as strings

c)

Gives the length of a string

d)

Splits a string into an array

59.

What does the PHP function strcmp do?

a)

Splits a string into an array

b)

Gives the length of a string

c)

Removes whitespace from the end of a string

d)

Compares two strings as strings

60.

What does the PHP function chop do?

a)

Compares two strings as strings

b)

Splits a string into an array

c)

Gives the length of a string

d)

Removes whitespace from the end of a string

61.

What will be the output of the PHP code shown in the example?

a)

ThisisIS448

b)

This IS448

c)

Thisis448

d)

This448is

62.

How many values does the boolean type have?

a)

One

b)

Two

c)

Three

d)

Four

63.

Which of the following values is NOT considered false in control expressions?

a)

The integer value 0

b)

The empty string

c)

The literal string "0"

d)

The literal string "1"

64.

What does NULL count as in boolean type?

a)

True

b)

False

c)

Undefined

d)

Not applicable

65.

Why should one be cautious with double calculations in boolean contexts?

a)

They are always true

b)

They are always false

c)

They can be unpredictable

d)

They rarely result in the exact value 0.0

66.

When does implicit type conversion occur according to the context in which an expression appears?

a)

When a string is used in a place where a boolean is required

b)

When a numeric value is required and a string is used

c)

When an array is used in a place where a string is required

d)

When an object is used in a place where a numeric value is required

67.

How is a string converted to an integer implicitly?

a)

When the string contains only letters followed by digits

b)

When the string contains only a sign followed by non-numeric characters

c)

When the string contains only a sign followed by digits

d)

When the string is a valid integer literal including a period or e or E

68.

What is the correct way to force a type conversion to integer in the C style?

a)

(double)$sum

b)

(int)$sum

c)

intval($sum)

d)

settype($sum, "integer")

69.

Which function can be used to determine the type of a variable?

a)

gettype

b)

settype

c)

is_type

d)

typeval