Explore topic-wise MCQs in Php.

This section includes 20 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

What will be the output of the following PHP code ?
<?php
$m = 5;
while (++$m)
{
while ($m > 0)
print $m;
}
?>

A. 0
B. Error
C. Nothing
D. 5
E. 66666666.......infinite time
Answer» F.
2.

What will be the output of the following PHP code ?
<?php
$number = 5;
while (++$number)
{
while ($number --> 0)
print $number;
}
?>

A. Error
B. 5
C. 543210
D. 0
E. None of these
Answer» D. 0
3.

What will be the output of the following PHP code ?
<?php
$t = 0;
while ((--$t > ++$t) - 1)
{
print $t;
}
?>

A. Error
B. 000000000........infinite time
C. 1111111.......infinite time
D. Nothing
E. None of these
Answer» C. 1111111.......infinite time
4.

What will be the output of the following PHP code ?
<?php
$num = 0;
while (++$num && --$num)
{
print $num;
}
?>

A. 0
B. Error
C. 0123457........infinite time
D. Nothing
E. None of these
Answer» D. Nothing
5.

What will be the output of the following PHP code ?
<?php
$n = 1;
while(++$n || --$n)
{
print $n;
}
?>

A. 2345678......infinite time
B. 12345678...........infinite time
C. Error
D. Nothing
E. None of these
Answer» B. 12345678...........infinite time
6.

What will be the output of the following PHP code ?
<?php
$m = 8;
while (--$m > 0 || ++$m)
{
print $m;
}
?>

A. Error
B. 76546211111........infinite time
C. 8
D. Nothing
E. None of these
Answer» C. 8
7.

What will be the output of the following PHP code ?
<?php
$k = 15;
while (--$k > 0 && ++$k)
{
print $k;
}
?>

A. Error
B. 15
C. Nothing
D. 15..........Infinite time
E. None of these
Answer» E. None of these
8.

What will be the output of the following PHP code ?
<?php
$p = 10;
while (--$p > 0)
{
$p++;
print $p;
print "INDIA";
}
?>

A. Error
B. 10
C. 0
D. 10INDIA......infinite time
E. None of these
Answer» E. None of these
9.

What will be the output of the following PHP code ?
<?php
$s = "";
while ($s = 20)
{
print "Interveiw";
}
print "Mania";
?>

A. Nothing
B. 20
C. Interview.....infinite time
D. Mania.....infinite time
E. None of these
Answer» D. Mania.....infinite time
10.

What will be the output of the following PHP code ?
<?php
$p = 5;
while($p = 20)
{
print "INDIA";
}
print "USA";
?>

A. 5
B. 20
C. USA
D. INDIA.....infinite time
E. USA.....infinite time
Answer» E. USA.....infinite time
11.

What will be the output of the following PHP code ?
<?php
while()
{
print "While loop...";
}
?>

A. Nothing
B. Error
C. While loop...
D. 0
E. None of these
Answer» C. While loop...
12.

What will be the output of the following PHP code ?
<?php
$num = 2;
while ($num < 5)
{
print "Interview";
$num--;
}
print "Mania";
?>

A. Error
B. Mania.......infinite time
C. Nothing
D. Interview......infinite time
E. None of these
Answer» E. None of these
13.

What will be the output of the following PHP code ?
<?php
$num = 2;
while ($num != 5)
{
print "Executed...";
$num++;
}
?>

A. Executed...
B. Executed...Executed...
C. Executed...Executed...Executed...
D. Executed...Executed...Executed...Executed...Executed...
E. None of these
Answer» D. Executed...Executed...Executed...Executed...Executed...
14.

What will be the output of the following PHP code ?
<?php
$n = 0;
do
{
print "$n";
$n++;
}
while ($n != 5);
?>

A. 0
B. 5
C. 01234
D. Error
E. None of these
Answer» D. Error
15.

What will be the output of the following PHP code ?
<?php
do
{
print "Interview";
}
while(0);
print "Mania";
?>

A. Mania
B. Interview
C. Error
D. InterviewMania
E. None of these
Answer» E. None of these
16.

What will be the output of the following PHP code ?
<?php
$t = 0;
while($t < 5)
{
$t++;
print "Ajit ";
}
?>

A. Ajit
B. Ajit Ajit
C. Ajit Ajit Ajit
D. Ajit Ajit Ajit Ajit
E. Ajit Ajit Ajit Ajit Ajit
Answer» F.
17.

What will be the output of the following PHP code ?
<?php
$n = "";
while($n)
{
print "Manjesh";
}
print "Ojha";
?>

A. Manjesh
B. Ojha
C. Error
D. Nothing
E. None of these
Answer» C. Error
18.

What will be the output of the following PHP code ?
<?php
$p = 0;
while ($p++)
{
print $p;
}
print $p;
?>

A. Error
B. 0
C. 1
D. Nothing
E. None of these
Answer» D. Nothing
19.

What will be the output of the following PHP code ?
<?php
$k = 10;
while ($k < 30)
{
$k++;
}
print $k;
?>

A. 30
B. 10
C. Error
D. Nothing
E. None of these
Answer» B. 10
20.

What will be the output of the following PHP code ?
<?php
$t = 20;
do
{
$t++;
}
while ($t < 60);
print $t;
?>

A. Error
B. 60
C. Nothing
D. 20
E. None of these
Answer» C. Nothing