Home

Php Programming MCQ Question with Answer

Php Programming MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Download Php Programming MCQ Question Answer PDF

Question No : 8

Which of the following PHP statements will output Hello World on the screen?
i) echo (“Hello World”);
ii) print (“Hello World”);
iii) printf (“Hello World”);
iv) sprintf (“Hello World”);


i) and ii)


i), ii) and iii)


All of the mentioned


i), ii) and iv)


Question No : 9
What will be the output of the following PHP code ?

 <?php  $i = 2;
while (++$i){ while ($i --> 0) print $i;
} ?>

210
10
no output
infinite loop

Question No : 10
What will be the output of the following PHP code ?

 <?php  $color1 = 1;
$color2 = 1;
echo $color1 + $color2;
?>

11
2
0
1

Question No : 11
What will be the output of the following code? If say date is 22/06/2013.

     <?php      echo Today is .date(F d, Y)     ?> 

Today is 22 June, 2013
Today is 22-06-2013
Today is 06-22-2013
Today is June 22, 2013

Question No : 12
What will be the output of the following PHP code?

 <?php  $cars = array(Volvo, BMW, Toyota, Honda, Mercedes, Opel);
print_r(array_chunk($cars, 2));
?>

Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) )
Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) )
Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) )
Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) )

Question No : 13
What will be the output of the following PHP code ?

 <?php  $i = 0;
while(++$i || --$i){ print $i;
} ?>

1234567891011121314….infinitely
01234567891011121314…infinitely
1
0

Question No : 14
What will be the output of the following PHP code ?

 <?php  class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>

test
error
myObject::CONSTANT
no output