wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP - Syntax & Output

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which symbol for variables in PHP?

a)

$

b)

&

c)

var()

d)
Type VarName
2.

Which of the following is syntax for single-line comment in PHP?

a)

#

b)

/*

c)

/* */

d)

//

3.

Which are PHP Arithmetic Operators?

a)

+

b)

/

c)

*

d)

All of the above

4.

How do you create an array in PHP?

a)

$cars = array["Blue", "Green", "Red"]; 

b)

$cars = array ("Blue", "Green", "Red");  

c)

cars = {"Blue", "Green", "Red"};

d)

cars[4] = {"Blue", "Green", "Red"};

5.

Choose correct way to declare variable in PHP

a)

var=1;

b)

$var = 1;

c)

define("var", 1);

d)

$100var=1;

6.

Identify the output

a)

twinkle little star

b)

Twinkle twinkle little star

c)

Twinkle

d)

little star

7.

Identify Output

a)

Kuala Selangor-KVKS 45

b)

Kuala Selangor -KVKS 45

c)

45-KVKS Kuala Selangor

d)

45 KVKS Kuala Selangor

8.

Which is an increment operator?

a)

+

b)

*

c)

++

d)

**

9.

Which is the correct PHP tag?

a)

<php … >

b)

<?php … ?>

c)

<?phpp … ?>

d)

<!php … !>

10.

Identify the output

a)

2

b)

3

c)

8

d)

9

11.

Which one of these variables has an ILLEGAL name?

a)

$my_Var

b)

$my-Var  

c)

&my_Var

d)

&my-Var

12.

How do you write "Hello World" in PHP?

a)

document.Write("Hello World");

b)

echo "Hello World";  

c)

cout << "Hello World!";

d)

System.out.println ("Hello World");

13.

What is the CORRECT way to end a PHP statement?

a)

}

b)

,

c)

;

14.

What is the CORRECT way to create a function in PHP?

a)

create myFunction()

b)

function myFunction()  

c)

class MyFunction{};

15.

What is the CORRECT way to add 1 to the $count variable?

a)

$count =+1

b)

$count++;