wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PHP Form

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What does PHP stand for?

a)

Hypertext Preprocessor

b)

Preprocessor Hypertext

c)

Personal Home Page

d)

Programming Hypertext Pages

e)

Portable Hypertext Processor

2.

Which method is used to retrieve variables from a URL in PHP?

a)

$_GET

b)

$_POST

c)

$_REQUEST

d)

$_COOKIE

e)

$_SESSION

3.

What is the main security risk when using the $_GET method to retrieve data?

a)

HTML or JavaScript injection

b)

SQL injection

c)

Cross-site request forgery (CSRF)

d)

Password brute forcing

e)

Data leakage in browser history

4.

Which PHP function is used to convert special characters into HTML entities to prevent security issues?

a)

htmlspecialchars()

b)

htmlentities()

c)

strip_tags()

d)

urlencode()

e)

addslashes()

5.

Which HTTP method should be used when submitting sensitive data, such as passwords, to a server?

a)

POST

b)

GET

c)

PUT

d)

DELETE

e)

CONNECT

6.

Which of the following is NOT a difference between GET and POST methods?

a)

GET appends data to the URL, while POST sends data in the HTTP body.

b)

GET is more secure than POST for sending sensitive data.

c)

POST does not append data to the URL.

d)

GET is limited by URL length, POST is not.

e)

GET requests can be bookmarked, POST requests cannot.

7.

What is the purpose of the $_REQUEST array in PHP?

a)

To collect values from both GET and POST methods

b)

To manage session data

c)

To track cookies

d)

To access files uploaded through forms

e)

To store form validation errors

8.

What is the purpose of the ‘action’ attribute in an HTML form?

a)

Specifies where to send the form data upon submission

b)

Specifies the HTTP method to use (GET or POST)

c)

Specifies the input elements to include in the form

d)

Specifies the type of encoding for the form data

e)

Specifies the server to receive the form data

9.

What does the htmlspecialchars() function do when handling form data?

a)

Converts special HTML characters to prevent XSS attacks

b)

Encrypts form data

c)

Strips HTML tags from the input

d)

Validates form input for correctness

e)

Converts form data into JSON format

10.

Which statement about POST method is true?

a)

It submits data in the HTTP message body.

b)

It appends data to the URL.

c)

It is limited to ASCII characters only.

d)

It stores parameters in browser history.

e)

It is always visible to everyone in the URL.

11.

Which PHP superglobal is used to get the values submitted by a form using the POST method?

a)

$_POST

b)

$_GET

c)

$_FILES

d)

$_SESSION

e)

$_COOKIE

12.

What is the benefit of using PHP includes for separating HTML and PHP code?

a)

Allows for cleaner and more maintainable code

b)

Increases the execution speed of PHP scripts

c)

Avoids database queries

d)

Automatically sanitizes form data

e)

Secures PHP code from public access

13.

Which method should be avoided when submitting sensitive information such as passwords or credit card numbers?

a)

GET

b)

POST

c)

PUT

d)

DELETE

e)

PATCH

14.

Which of the following is a valid URL query string format for passing multiple variables?

a)

name1=value1&name2=value2

b)

name1,value1;name2,value2

c)

name1:value1/name2:value2

d)

name1-value1&name2-value2

e)

name1/value1|name2/value2

15.

What is the main advantage of using POST over GET when submitting form data?

a)

POST does not expose form data in the URL.

b)

POST can send more data.

c)

POST is easier to debug.

d)

POST supports only ASCII characters.

e)

POST stores form data in browser history.

16.

What PHP function checks whether a variable is set?

a)

isset()

b)

empty()

c)

is_null()

d)

define()

e)

isset_value()

17.

In PHP, how do you access multiple form variables sent via GET in the URL?

a)

$_GET['var_name']

b)

$_POST['var_name']

c)

$_SERVER['var_name']

d)

$_REQUEST['var_name']

e)

$_SESSION['var_name']

18.

What does the “Monokai” theme refer to in the context of PHP development?

a)

A color scheme in VS Code

b)

A PHP coding style guide

c)

A database management tool

d)

A web server configuration

e)

A templating engine

19.

What is the primary purpose of a PHP template file?

a)

To insert dynamically generated content into an HTML structure

b)

To handle form validation

c)

To manage database queries

d)

To configure server-side settings

e)

To execute background PHP processes

20.

What is the difference between $_GET and $_POST in PHP?

a)

$_GET retrieves data from the URL, $_POST retrieves data from the body of the HTTP request.

b)

$_GET retrieves data from cookies, $_POST retrieves data from sessions.

c)

$_GET retrieves data from files, $_POST retrieves data from forms.

d)

$_GET retrieves data from databases, $_POST retrieves data from APIs.

e)

$_GET retrieves sensitive data, $_POST retrieves non-sensitive data.