Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP Basics Quiz

Total questions: 29

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is used to declare a variable in PHP?

a)

$var_name

b)

var var_name

c)

@var_name

d)

#var_name

2.

Which symbol is used to concatenate strings in PHP?

a)

+

b)

&

c)

.

d)

#

3.

What is the default extension of a PHP file?

a)

.html

b)

.xml

c)

.php

d)

.js

4.

Which of the following is NOT a valid PHP data type?

a)

Boolean

b)

Integer

c)

String

d)

Real

5.

Which method sends form data as part of the URL?

a)

GET

b)

POST

c)

REQUEST

d)

SUBMIT

6.

Which of the following is used to include one PHP file into another?

a)

add()

b)

import()

c)

include()

d)

require_once()

7.

Which PHP superglobal collects GET data?

a)

$_FORM

b)

$_POST

c)

$_GET

d)

$_REQUEST

8.

Which method is more secure for sensitive data like passwords?

a)

GET

b)

POST

c)

COOKIE

d)

SERVER_METHOD

9.

What attribute is required in the form tag to send data?

a)

name

b)

action

c)

value

d)

required

10.

Which HTML input type sends the form?

a)

type="reset"

b)

type="text"

c)

type="submit"

d)

type="button"

11.

How do you get a POST value in PHP?

a)

$_POST['name']

b)

$_GET['name']

c)

$POST['name']

d)

getPost('name')

12.

Which is not a valid form method?

a)

GET

b)

POST

c)

SEND

d)

REQUEST

13.

Which function starts a session in PHP?

a)

begin_session()

b)

start_session()

c)

session_start()

d)

init_session()

14.

How do you store a session variable?

a)

$_SESSION['user'] = "Ali";

b)

$_SESSION = "Ali";

c)

session['user'] = "Ali";

d)

$SESSION['user'] = "Ali";

15.

How can you delete all session variables?

a)

session_end()

b)

session_unset()

c)

session_destruct()

d)

unset_session()

16.

What does CRUD stand for?

a)

Create, Run, Update, Delete

b)

Create, Read, Update, Delete

c)

Create, Remove, Update, Drop

d)

Create, Retrieve, Upload, Drop

17.

Function to connect MySQL in PHP?

a)

mysql_connect()

b)

mysqli_connect()

c)

db_connect()

d)

connect_db()

18.

SQL statement to insert data?

a)

ADD

b)

INSERT INTO

c)

PUT INTO

d)

CREATE

19.

Execute query in PHP using MySQLi?

a)

mysqli_query($conn, $sql)

b)

mysql_query($sql)

c)

execute_query($sql)

d)

query_exec($conn, $sql)

20.

Fetch result as associative array?

a)

mysqli_fetch_array()

b)

mysqli_fetch_row()

c)

mysqli_fetch_assoc()

d)

fetch_result()

21.

Used to update records in DB?

a)

UPDATE

b)

CHANGE

c)

MODIFY

d)

SET

22.

Used to delete a record?

a)

REMOVE

b)

DELETE

c)

ERASE

d)

DROP

23.

Which is NOT a valid SQL command?

a)

INSERT

b)

SELECT

c)

FETCH

d)

DELETE

24.

Count rows in a result set?

a)

mysqli_num_rows()

b)

count_rows()

c)

get_rows()

d)

row_count()

25.

What does WHERE clause do?

a)

Filters records

b)

Sorts records

c)

Joins tables

d)

Groups records

26.

What is required before using $_SESSION?

a)

echo

b)

include()

c)

session_start()

d)

session_init()

27.

Function to destroy a session?

a)

end_session()

b)

session_destroy()

c)

destroy_session()

d)

remove_session()

28.

Check if session variable is set?

a)

isset($_SESSION['user'])

b)

if($_SESSION)

c)

session_exists('user')

d)

$_SESSION->exists('user')

29.

Correct syntax for a while loop in PHP?

a)

while i < 10 { }

b)

while (i < 10) { }

c)

while ($i < 10) { }

d)

loop while ($i < 10) { }