wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PHP BASIC

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

Insert the missing part of the code below to output "Hello World".

a)

echo and print

b)

System.out.println

c)

println

d)

cout

2.

Write the correct opening tag and close tag for PHP scripts.

a)

{}

b)

<?php ?>

c)

<>

d)

<? ?>

3.

Statements in PHP have to end with a special character, which one?

a)

.

b)

,

c)

:

d)

;

4.

Create a variable in php assign with the

a)

String

b)

const

c)

let

d)

$

5.

Get the length of the string "Hello World!".

a)

Leng

b)

substring

c)

strlen

d)

len

6.

Use the correct function to output the number of items in an array.


$fruits = array("Apple", "Banana", "Orange");

a)

echo $fruits[0]

b)

echo $fruits["Apple"]

c)

echo count($fruits)

d)

echo $fruits[0][1]

7.

Write a correct syntax to include a file named "footer.php".

a)

include ("footer.php");

b)

import("footer.php");

c)

required("footer.php");

d)

export("footer.php");

8.

Assume we have a file named "webdict.txt", write the correct syntax to open and read the file content.

a)

readfile("webdict.txt")

b)

openfile("webdict.txt")

c)

writefile("webdict.txt")

d)

modifyfile("webdict.txt")

9.

Create a cookie named "username".

a)

setcookie = ("username", "John", time() + (86400 * 30), "/");

b)

setcookie("username", "John", time() + (86400 * 30), "/");

c)

session("username", "John", time() + (86400 * 30), "/");

d)

setsession("username", "John", time() + (86400 * 30), "/");

10.

Create a session variable named "favcolor".

a)

$session["favcolor"] = "green";

b)

$_SESSION["favcolor"] = "green";

c)

$_SESSION["favcolor"] ["green"];

d)

$SESSION["favcolor"] ="green";