wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Introduction to PHP

Total questions: 60

Worksheet time: 45mins

Name
Class
Date
1.

Which tag is used for php

a)

<?php

?>

b)

<style>

c)

<php ?>

d)

<php

/php>

2.

What are the types of array in php

a)

Indexed, sequence

b)

Associative, sequence

c)

Indexed, associative

d)

None

3.

In php the keyword to be used before function name is

a)

Function

b)

Static

c)

function

d)

FUNCTION

4.

HTML stands for

a)

Hyper Text Machine Language

b)

Hyper Text Markup Language

c)

Hyper Technical Machine Language

d)

None of these

5.

Which one of the following is a form element?

a)

text box.

b)

radio button.

c)

submit button.

d)

All of these.

6.

What is the output of the PHP code.

<?php

if(4>5)

{print("Hurray..");}

print("yes");

?>

a)

Yes

b)

hurray..yes

c)

Hurray..Yes

d)

none of the above

7.
PHP Scripts starts with ________
a)
<php> … </php>
b)
<?php …. ?/>
c)
<?=........?>
d)
?php … ?php
8.

What type of language is PHP

a)

Client Side

b)

Server Side

c)

Browser Side

d)

Web Side

9.

PHP is executed on

a)

The Server

b)

The Browser

c)

The Website

d)

The Machine

10.

We store small snippets of information inside what?

a)

Functions

b)

Loops

c)

If Statements

d)

Variables

11.

We create re-usable code blocks by placing them inside?

a)

Variables

b)

Parameters

c)

Code Blocks

d)

Functions

12.

Sometimes we only want certain code to execute if a condition is true. How do we test for that?

a)

Loop

b)

If Statement

c)

Integer

d)

Variable

13.

What is a integer?

a)

It's a Whole Number

b)

It's a Decimal Number

c)

It's a True or False Declaration

d)

It's a String of Text

14.

What is a String?

a)

Text

b)

Number

c)

True

d)

Loop

15.

What is a Boolean

a)

It's Just Text

b)

It's a Number

c)

It's Just True

d)

It's True or False

16.

What if we want a block of code to execute several times?

a)

Use a Variable

b)

Use a Function

c)

Use a Loop

d)

Use a Leap

17.

$colours = array("black, blue, Red, Green") - How do I access "Red" ?

a)

$colours[0];

b)

$colours[2];

c)

$colours[1]

d)

$colours[3];

18.

How do I print out the values of the variable "name" ?

a)

$name;

b)

include $name;

c)

echo $name;

d)

echo $name

19.

function sayMyName(name) {} ; - How do I call tat function

a)

sayMyname();

b)

$sayMyName;

c)

$sayMyName();

d)

sayMyName("John")';

20.

What does i++ do ?

a)

Adds the text on to the end of i

b)

Adds i on to the end of something

c)

Adds i on to the existing value of i

d)

Adds 1 to the current value of iThis is a correct answer

21.

What type of variable is this: $isMale = false;

a)

Integer

b)

Boolean

c)

String

d)

char

22.

In an IF statement we can have 2 conditions tested. Which keyword allows this?

a)

Else

b)

if Else

c)

Else if

d)

OR

23.

$a = 4 ; $b = 6; $c = $a + $b; What is the value of variable "c" ?

a)

6

b)

8

c)

10

d)

None

24.

$a = "Ram"; $n = "Kumar"; $fullName = $f + $n; What is the value of $fulName

a)

RamKumar

b)

Ram Kumar

c)

Ram

d)

None

25.

$a = "Ram"; $n = "Kumar"; $fullName = $f . $n; What is the value of $fulName

a)

RamKumar

b)

Ram Kumar

c)

Kumar

d)

None

26.

Function calls can have____________ inside them.

a)

Parameters

b)

Arguments

c)

Variables

d)

Types

27.

PHP is a ............

a)

Open Source Language

b)

Widely Used Language

c)

Server side scripting language

d)

All of the above

28.

Which of the following symbol is used to add multiple line comments in PHP ?

a)

//

b)

/* */

c)

{{ }}

d)

{/ \}

29.

How to define a function in PHP?

a)

function {function body}

b)

function functionName(parameters) {function body}

c)

functionName(parameters) {function body}

d)

None of the above

30.

Which of the following is used for concatenation in PHP?

a)

+ (plus)

b)

* (Asterisk)

c)

. (dot)

d)

append()

31.

Which of the following is the correct way of defining a variable in PHP?

a)

$variable name = value;

b)

$variable_name = value;

c)

$variable_name = value

d)

$variable name as value;

32.

Which of the following is the correct way to create an array in PHP?

a)

$season = array["summer" , "winter" , "spring" , "autumn"];

b)

$season = array("summer" , "winter" , "spring" , "autumn");

c)

$season =( "summer" , "winter" , "spring" , "autumn");

d)

All of the above

33.

What will be the output of the following program?

<?php

$a = 15;

function show() {

$a = 20; echo "$a";

}

show();

echo "$a";

?>

a)

2020

b)

2015

c)

1515

d)

0

34.

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

a)

echo and print

b)

System.out.println

c)

println

d)

cout

35.

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

a)

.

b)

,

c)

:

d)

;

36.

Create a variable in php assign with the

a)

String

b)

const

c)

let

d)

$

37.

What does PHP stands for?

a)

PHP: Hypertext Preprocessor

b)

Private Home Page

c)

Personal Hypertext Processor

38.

The if statement is used to execute some code only if a specified condition is true

a)

True

b)

False

39.

<!DOCTYPE html>

<html>

<body>


<h1>My first PHP page</h1>


<?php

echo "Hello World!";

?>


</body>

</html>

a)

My first PHP page

Hello World!

b)

Hello World!

c)

My first PHP page

d)

echo "Hello World!";

40.

<!DOCTYPE html>

<html>

<body>


<?php

ECHO "Hello World!<br>";

echo "Hello World!<br>";

EcHo "Hello World!<br>";

?>


</body>

</html>

The Result..?

a)

Hello World!

Hello World!

Hello World!

b)

Hello World!

c)

Hello World!

Hello World!

d)

Hello World!

Hello World!

Hello World!

Hello World!

41.

PHP is free to download and use

a)

False

b)

True

42.

PHP files can contain text, HTML, CSS, JavaScript, and PHP code

a)

True

b)

False

43.

<!DOCTYPE html>

<html>

<body>


<?php

$color = "red";

echo "My car is " . $color . "<br>";

echo "My house is " . $COLOR . "<br>";

echo "My boat is " . $coLOR . "<br>";

?>


</body>

</html>

the result..?

a)

My car is red

My house is

My boat is

b)

My car is red

My house is

c)

My car is red

44.

<!DOCTYPE html>

<html>

<body>


<?php

$txt = "Hello world!";

$x = 5;

$y = 10.5;


echo $txt;

echo "<br>";

echo $x;

echo "<br>";

echo $y;

?>


</body>

</html>

the result..?

a)

Hello world!

5

10.5

b)

Hello world!

c)

5

d)

10.5

45.

How do you create an array in PHP?

a)

$cars = array("Volvo","BMW","Toyota");

b)

$cars = "Volvo","BMW","Toyota";

c)

$cars = array["Volvo","BMW","Toyota"];

46.

Which operator is used to check if two values are equal and of same data type?

a)

=

b)

==

c)

===

d)

!=

47.

A server-side scripting language designed for web development is ...

a)

HTML

b)

PHP

c)

C++

d)

C#

48.

The script is used to display the output of parameters that are passed to it is ...

a)

PRINT

b)

ECHO

c)

SELECT

d)

INSERT

49.

Comments in PHP are written with ...

a)

$

b)

//

c)

<!-- ... -->

d)

" ... "

50.

The correct way to print out the values of the variable "name" is ...

a)

$name;

b)

include $name;

c)

echo $name;

d)

echo $name

51.

<?php

$number = 20;

if($number < 10){

echo "SMA ABBS";

}else{

$sum = $number + 10;

echo "$sum";

}

?>

The output is ...

a)

SMA ABBS

b)

20

c)

30

d)

Error

52.

The "**" operator belongs to which category of operators?

a)

Arithmetic operator

b)

Logical operator

c)

Comparison operator

d)

Conditional operator

53.

What is the correct output of the given code <?php

$NUM1 = 3;

$NUM2 = 4;

$NUM3 = $NUM1 ** $NUM2;

echo $NUM3;

?>

a)

12

b)

81

c)

Garbage Value

d)

None of the above

54.

Which of the following are comparison operators in PHP?

A. ==

B. !=

C. ===

D. < = >

a)

A and B

b)

C and D

c)

A,B and C

d)

A,B,C and D

55.

What is the Output


<?php

$color=red;

echo "$color";

?>

a)

red

b)

$color

c)

No answer

d)

Error

56.

A

function name cannot start with a ____

a)

alphabet

b)

underscore

c)

number

d)

Both C

and B

57.

HTML

page can be access using _______ protocol.

a)

HTTP

b)

FTP

c)

SMTP

d)

POP

58.

Which among the following is NOT a type of loops?

a)

if

b)

for

c)

while

d)

do while

59.

Which among the following is NOT type of array

a)

Unindexed

b)

Indexed

c)

Associative

d)

Multidimensional

60.

6.

In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings. Is this statement TRUE or FALSE?

a)

TRUE

b)

FALSE