wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PHP First Internal Practical Viva

Total questions: 20

Worksheet time: 31mins

Name
Class
Date
1.

Type your full name

4 lines
2.

Type your full Reg No

4 lines
3.

Type your campus ID

4 lines
4.

Choose your Course (MCA/MSc)

a)

MCA

b)

MSc

5.

Which of the following php statement/statements will store 111 in variable num?

a)

int $num = 111;

b)

int mum = 111;

c)

$num = 111;

d)

111 = $num;

6.

What will be the output of the following php code

< ?php

$num = 1;

$num1 = 2;

print $num . "+". $num1 ;

?>

a)

3

b)

1+2

c)

1.+.2

d)

Error

7.

What will be the output of the following PHP code?

< ?php

$fruits = array ("mango", "apple", "pear", "peach");

$fruits = array_flip($fruits);

echo ($fruits[0]);

?>

a)

mango

b)

Error

c)

peach

d)

0

8.

What will be the output of the following code?

$Rent = 250;

function Expenses($Other) {

$Rent = 250 + $Other;

return $Rent; }

Expenses(50);

echo $Rent;

a)

300

b)

250

c)

200

d)

Program will not compile

9.

In multidimensional arrays rather than a single key they values are stored in

a)

Sequence of key values

b)

2 keys

c)

linear style

d)

None of them

10.


In PHP, which character is used at the end of each statement?

(a)  

11.

Which of the following is a correct way to define a constant in PHP?

a)

define('CONST_NAME', 'Value');

b)

const CONST_NAME = 'Value';

c)

Both a and b

d)

None of the above

12.

In PHP, variable names must start with which of the following.

a)

No numbers

b)

Letters

c)

Underscore

d)

All of the above

13.

Identify the function which converts a string to uppercase.

a)

uppercase()

b)

str_uppercase()

c)

strtoupper()

d)

struppercase()

14.

Which of the following function is used to sort array in descending order?

(a)  

15.

Spot the error in the following PHP code:
for ($i = 0; $i <= 10; $i++) {
echo $i; } echo $i;
?>

a)

Undefined variable outside loop

b)

Missing semicolon

c)

No error in the code

d)

Syntax error in loop

16.

Which superglobal array in PHP contains information about headers, paths, and script locations?

a)

$_GET

b)

$_POST

c)

$_SERVER

d)

$_FILES

17.

What is the correct way to check if a form has been submitted in PHP?

a)

Checking if $_POST is set

b)

Checking if $_SERVER['REQUEST_METHOD'] is POST

c)

Checking if $_GET is set

d)

Checking if $_REQUEST is set

18.

Spot the error in the following PHP form handling code:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo $_POST[name];
}
?>

a)

Missing quotes around array key name

b)

No error in the code

c)

Syntax error in if statement

d)

Missing semicolon in echo statement

19.


What will be the output of the following PHP code?
$i = 0;
while($i < 3) {
echo $i;
$i++;
}
?>

(a)  

20.

What two key words best describe your experience and learning from this lab viva?

2 lines