PHP Programming Quiz


Play this quiz that will help you to excel in PHP certification exams, placements etc. This PHP programming quiz consist of 10 questions that you need to solve in 10 minutes. We’ve specially designed this quiz so that you can quickly acquaint to the pattern of questions you can be asked in placement drives, certification exams etc. This PHP programming test enables you to assess your knowledge of PHP programming.

Take the Free Practice Test



PHP MCQs

Practice PHP MCQ Questions, which will help you to clear your PHP Programming related concepts and also helps you to prepare for placements, technical rounds, interviews, competitive exams etc.

PHP Quiz

Try Free PHP Quiz, to start a quiz you need to login first, after login you will get start quiz button and then by clicking on that you can start quiz. You will get 10 Minutes to answer all questions.

PHP Quiz

1. What will be the output of the following PHP code ?

<?php
$i = 0;
$j = 0;
first: while ($i < 2)
{
 $i++;
  while ($j < 3)
    {
     $j++;               
      echo("loop
");
      if($j%2==0)
         continue;
      goto first;
    }
}
?>

prints "loop" infinite times
prints "loop" 1 times
prints "loop" 2 times
prints "loop" 3 times

2. What will be the output of the following PHP code?

<?php   
  $arr = array (10, 20, 30); 
    foreach ($arr as $val) {  
        echo "$val1 \n"; 
    }  
?>

10 20 30
No Output
10
undefined variable

3. Objects are defined as instances of user defined classes that can hold ____________?

values
functions
both values and functions
None of the above

4. What is the output of the following php code?

<?php
    $username = "letsfindcourse";
    if (preg_match("([^a-z])",$username))
        echo "Name must be all lowercase!";
    else
        echo "Name is all lowercase!";
    ?>

Error
No Output
Name must be all lowercase!
Name is all lowercase!

5. Which of the following is the output of the below code?

<?php
   class lfc { 
  
      var $mcq_type; 
     
      function setmcq_type($par){ 
         $this->mcq_type = $par; 
      } 
        
      function getmcq_type(){ 
         echo $this->mcq_type."<br>"; 
      } 
        
   } 
  
  
   $obj = new lfc; 
  
 
   $obj->setmcq_type("Objects Mcq"); 
   $obj->getmcq_type(); 
?> 

Objects Mcq
Objects Mcq ""
Error
No Output

6. Which is true about var_dump() function?

var_dump() loops infinitely
var_dump() cuts off loop afetr getting same element two times
var_dump() cuts off loop after getting the same element three times
var_dump() cuts off loop after getting the same element five times

7. In Which php version Exception handling was added?

PHP 5.1
PHP 5.2
PHP 5.3
PHP 5

8. Which one of the following functions is used to determine whether a class exists?

exist()
exist_class()
class_exist()
__exist()

9. How many methods are available for the exception class?

five
six
seven
eight

10. What will be the output of the following PHP code?

<?php  
  
for ($num = 1; $num <= 10; $num += 2) { 
    echo "$num "; 
}  
  
?>

1 3 5 7 9
1 2 3 4 5
9 7 5 3 1
Error

Results