wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP Basics

Total questions: 54

Worksheet time: 54mins

Name
Class
Date
1.

PHP is a____________side scripting language

a)

server

b)

browser

c)

client

2.

PHP stands for

a)

Hypertext processor

b)

Homepage processor

c)

Hypertext preprocessor

3.

Who is known as father of PHP

a)

Rasmus Lerdorf

b)

Brendan Eich

c)

Hakon Wium Lie

4.

PHP scripts are enclosed within ___

a)

<php> . . . </php>

b)

<?php . . . ?>

c)

?php . . . ?php

5.

Variables used in php

a)

$a=5;

b)

var a=5;

c)

int a=5;

6.

_______ is a concatenation operator in php

a)

+ (plus)

b)

+=

c)

. (dot)

7.

Find the output

<?php

$x = 5;

{ $x = 10;

echo $x;

}

echo $x;

?>

a)

105

b)

510

c)

1010

8.

find the output

<?php

$x = 1;

$x += 1;


echo $x;

?>

a)

2

b)

1

c)

0

9.

PHP Scripts are executed using

a)

XAMPP

b)

JAVA

c)

EDITOR

d)

NONE

10.

Arrays are created using

a)

Arrays()

b)

array()

c)

aray()

d)

array[]

11.

Where is your PHP project file located?

a)

C:\xampp\htdocs\

b)

C:\xampp\project\

c)

D:\xampp\htdocs\

12.

The 2 basic ways to get output in PHP are __________.

a)

echo and cout

b)

echo and scan

c)

echo and print

13.

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;

14.

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

a)

6

b)

8

c)

10

d)

None

15.

How do you get information from a form that is submitted using the "get" method?

a)

Request.QueryString;

b)

$_GET[];

c)

Request.Form;

16.

Which one of the following is the right way of defining a function in PHP?

a)

function { function body }

b)

data type functionName(parameters) { function body }

c)

functionName(parameters) { function body }

d)

function functionName(parameters) { function body }

17.

Associative arrays are a ____ pair data structure.

a)

Single value

b)

Key value

c)

Double value

d)

String value

18.

Which of the following is used to delete a cookie?

a)

setcookie() function

b)

$_COOKIE variable

c)

isset() function

d)

unsetcookie() function

19.

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

a)

$colours[0];

b)

$colours[2];

c)

$colours[1]

d)

$colours[3];

20.

$a=array("Timmy","Jimmy");

Is an example of

a)

Indexed array

b)

Associative array

c)

Sequence array

d)

None

21.

What does X mean in XAMPP?

a)

Cross Form Operating System

b)

Cross Combination of PHP and MySQL

c)

Cross Platform Operating System

d)

Cross Programming Languange used

22.

What is the standard format for declaring variables in PHP?

a)

Variable names must start with a dollar sign followed by a character and a letter and must not contain spaces

b)

Declaring a variable must start with a dollar sign, the variable name must start with a letter followed by other characters, and must not contain any spaces.

c)

Declaring a variable must start with a dollar sign, and the variable name must start with a letter followed by other characters and contain any spaces.

d)

Declaring a variable must start with a dollar sign, the variable name must start with followed by a character and a leter and it must contain any spaces.

23.

What conditional statement that is used to perform different actions based on different conditions and to avoid long block of if-else-if else conditional statement?

a)

PHP if() Statement

b)

PHP if-else() statement

c)

PHP if-else-if() statement

d)

Switch Case statement

24.

What are the appropriate PHP cides for instantiating an indexed array in PHP with the given list?

List of the electronic Brands

-HP

-Acer

-Apple

-Dell

a)

$e brands=array("HP"."Acer"."Apple"."Dell");

b)

$ebrands=array("HP","Acer"."Apple","Dell");

c)

$ ebrands=array("HP","Acer","Apple","Dell");

d)

$ebrands=array("HP","Acer","Apple","Dell");

25.

What are the appropriate PHP codes to display the Banana in the given array?

<?php  $fruits = array("Apple", "Banana", "Orange"); ?>

a)

Echo $fruits[2];

b)

echo $fruits[1]:

c)

echo $fruits[1];

d)

echo $fruit[2];

26.

Which one of the following statements is used to create a table?

a)

CREATE TABLE table_name (column_type column_name);

b)

CREATE table_name (column_type column_name);

c)

CREATE TABLE table_name (column_name column_type);

d)

CREATE table_name (column_name column_type);

27.

Which of the following is the use of strlen() function in PHP?

a)

The strlen() function returns both value and type of string

b)

The strlen() function returns the length of string

c)

The strlen() function returns the type of string

d)

The strlen() function returns the value of string

28.

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

29.

Which of the following function converts a string to all uppercase?

a)

upper()

b)

strtoupper()

c)

struppercase()

d)

uppercase()

30.

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

31.

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

32.

Which method is more secure send the data to server

a)

post

b)

get

c)

request

d)

none

33.

<?php $fruits = array ("apple", "orange", array ("pear", "mango"),"banana");

echo (count($fruits, 1)); ?>

What is the output of the php code?

a)

5

b)

4

c)

6

d)

3

34.

Which superglobal variable holds information about headers, paths, and script locations?

a)

$GLOBALS

b)

$_GET

c)

$_SERVER

d)

$_SESSION

35.

What is the output?


<?php

define(GREETING, " PHP is a Scripting Language");

echo "$GREETING;

?>

a)

$GREETING

b)

no output

c)

GREETING

d)

PHP is a Scripting Language

36.

<?php

$x=10;

$y=4;

$z=3;

echo ($x % ($y) + $z);

?>

a)

5

b)

3

c)

0

d)

1

37.

What is the Output?

<?php

$four4 =4;

$three3 = 3;

$two2 = 2;

echo " $four4 + $three3 / $two2 - 1"

a)

4.5

b)

7

c)

3.5

d)

Error

38.

What is the Output:

<?php

$color= "red";

echo "$color";

echo "$COLOR";

echo "$Color";

?>

a)

redredred

b)

redred

c)

red

d)

Error

39.

What will be the value of $result after the following code executes?

$x = 5;

$y = 3;

$result = ($x > 2) && ($y < 10);

a)

true

b)

false

c)

error

40.

What are the two types of array in php

a)

Indexed, sequence

b)

Associative, sequence

c)

Indexed, associative

d)

None

41.

function add()

{

$a=10;

echo $a;}

This is an example for

a)

Call by value

b)

Call by reference

c)

None

d)

Both

42.

function add(&a)

{

$a=10;

echo $a;}

$a=33;

This is an example for

a)

Call by value

b)

Call by reference

c)

Both of the above

d)

None

43.

Which one of the following is a form element?

a)

text box.

b)

radio button.

c)

submit button.

d)

All of these.

44.

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]

45.

What is the output of the following PHP code?

<?php

$num = 10;

function multiply() {

$num = 5;

return $num * 2;

}

echo $num + multiply();

?>

a)

20

b)

25

c)

30

46.

Which PHP function is used to check if a variable is an array or not?

a)

is_array()

b)

check_array()

c)

validate_array()

47.

What will be the output of the following PHP code?

<?php

$str = "Hello World!";

echo strrev($str);

?>

a)

Hello World!

b)

!dlroW olleH

c)

dlroW olleH!

48.

Your full name

4 lines
49.

Your Reg No

4 lines
50.

Your Campus ID

4 lines
51.

Course (MCA or MSc)

4 lines
52.

How would you rate the difficulty level of the quiz?

a)

Easy

b)

Moderate

c)

Difficult

d)

Very difficult

53.

Were you able to complete the quiz within the given time frame?

a)

Yes, easily

b)

Yes, but it was challenging

c)

No, ran out of time

d)

Did not attempt within the time frame

54.
  1. Any suggestions for improving future quizzes or study materials?

4 lines