1.  Which of the following php statement/statements will store 111 in variable num ?
i. int $num = 111;
ii. int mum = 111;
iii. $num = 111;
iv. 111 = $num;


Both i and ii
All of the mentioned
Only iii
Only i


Answer

 Option

You need not specify the datatype in php.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

2.  Which of the following must be installed on your computer so as to run PHP script ?
i. Adobe Dreamweaver
ii. PHP
iii. Apache
iv. IIS


All of the mentioned
Only ii
ii and iii
ii, iii and iv


Answer

 Option

To run PHP code you need to have PHP and a web server, both IIS and Apache are web servers. You can choose either one according to your platform.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

3.  What will be the output of the following php code ?
$num = ‘’1’’;
$num1 = ‘’2’’;
print $num+$num1 ;
?>


3
1+2
Error
12


Answer

 Option

The numbers inside the double quotes are considered as integers and not string, therefore the value 3 is printed and not 1+2.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

4.  What will be the output of the following PHP code ?
$total = ‘’25 students’’;
$more = 10;
$total = $total + $more;
echo ‘’$total’’;
?>


Error
35 students
35
25 students


Answer

 Option

The integer value at the beginning of the original $total string is used in the calculation. However if it begins with anything but a numerical value, the value will be 0.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

5.  What will be the output of the following PHP code ?
$score = 1234;
$scoreboard = (array) $score;
echo $scoreboard[0];
?>


1
Error
1234
2


Answer

 Option

The (array) is a cast operator which is used for converting values from other data types to array.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report