PHP MCQ: PHP Multiple Choice Questions and Answers

PHP MCQ with answers and explanations for placement tests and job interviews. These solved PHP MCQs are useful for the campus placement for all freshers including Engineering Students, MCA students, Computer and IT Engineers, etc.

Our PHP MCQ (PHP Multiple Choice Questions ) focuses on various parts of the PHP programming language and its concept. It will be useful for anyone learning PHP Basics, Essentials, and/or Fundamentals. We will regularly update the quiz and most interesting thing is that questions come in a random sequence. So every time you will feel new questions.

You may have come across several PHP courses during your search for learning the PHP language. Our team of experts has carefully analyzed some PHP courses for you. You can check the courses, Trial of some courses is free.

 

Guideline of PHP MCQ:

This PHP MCQ is intended for checking your PHP programming knowledge. It takes 40 minutes to pass the PHP MCQ. If you don’t finish the PHP MCQ within the mentioned time, all the unanswered questions will count as wrong. You can miss the questions by clicking the “Next” button and return to the previous questions by the “Previous” button. Every unanswered question will count as wrong. MCQ on PHP has features of randomization which feel you a new question set at every attempt.

In this PHP MCQ, we have also implemented a feature that not allowed the user to see the next question or finish the PHP quiz without attempting the current PHP MCQ.

0 votes, 0 avg

You have 40 minutes to take the PHP MCQs

Your time has been Over.


PHP MCQ

PHP MCQ

PHP MCQ: PHP Multiple Choice Questions and Answers

1 / 39

Why does this code trigger an error?

$string = 'Shylock in a Shakespeare's "Merchangt of Venice" demands his pound of flesh.';

 

2 / 39

Which php control structure is used inside a loop to skip the rest of the current loops code and go back to the start of the loop for the next iteration

3 / 39

The php not operator is !. Given the snippet, is there an out put and what is it?

4 / 39

What is missing from this code, which is supposed to create a test cookies?

1 $string_name = " testcookie";
2 $string_value = "This is a test cookie";
3 $expiry_info = info()+259200;
4 $string_domain = "localhost.localdomain";

 

5 / 39

You are using the following code to find a users band, but it is returning false. Which step(s) would solve the problem?

isset (\$\_GET['fav_band'])

 

6 / 39

In a conditional statement, you want to execute the code only if both value are true. Which comparison operator should you use?

7 / 39

Both triple === and double == can be used to **_ variables in php. If you want to hear that string "33" and the number 33 are equal, you would use ** . If you want to check if an array contains a particular string value at a particular index, you would use ___

8 / 39

Which is the way to create an array of "seasons"?

9 / 39

Which is the most secure way to avoid storing a password in clear text in database?

10 / 39

Which code snippet uses the correct syntax for creating an instance of the Pet class?

11 / 39

A PDO object called $db has been set up to use for database operations, including user authentication. All user-related properties are set. The script line public function __construct(&$db) shows a constructor that initializes all user-related properties to ____ if no user has logged in. These parameters will be properly set by the login functions when a user logs in.

12 / 39

What is the value of $total in this calculation?

$total = 2 + 5 * 20 - 6 / 3

 

13 / 39

Which code would you use to print all the elements in an array called $cupcakes?

14 / 39

What is the significance of the three dots in this function signature?

function process(...$vals) {
        // do some processing
 }

 

15 / 39

In the following script, which line(s) will cause an error(s)?

1 <?php
2       $count = 0
3       $_xval = 5
4       $_yval = 1.0
5       $some_string = "Hello there!";
6       $some_string = "How are you?";
7       $will i work = 6;
8       $3blindmice = 3;
9 ?>

 

16 / 39

Which is the correct format for adding a comment to a PHP script?

17 / 39

The **_ operator is useful for sorting operations. It compares two values and returns an integer less than, equal to, or greater than 0 depending on whether on whether the value on the _**is less than, equal to, or greater than the other.

18 / 39

You want to list the modules available in your PHP installation. What command should you run?

19 / 39

Which value equates to true?

20 / 39

Assuming the Horse class exists, which is a valid example of inheritance in PHP?

21 / 39

What is the value of '$result' in this calculation?

$result = 25 % 6;

 

22 / 39

What is the cause of 'Cannot modify header information - headers already sent'?

23 / 39

What will this code print?

$mathe=array('archi','euler','pythagoras');
array_push($mathe,'hypatia');
array_push($mathe,'fibonacci');
array_pop($mathe);
echo array_pop($mathe);
echo sizeof($mathe);

 

24 / 39

Which line could you NOT use to comment out "Space: the final frontier"?

25 / 39

What does this script do?

1 $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
2 if ($email === false) {
3  $emailErr = "Please re-enter valid email";
4 }

 

26 / 39

What does this code output?

echo 76 &lt;=&gt; '76 trombones';

 

27 / 39

Your php page is unexpectedly rendering as totally blank. Which step will shed light on the problem?

28 / 39

All variables in PHP start with which symbol?

29 / 39

Both self and this are keywords that can be used to refer to member variables of an enclosing class. The difference is that $this->member should be used for __ members and self::$member should be used for __ members.

30 / 39

What is the purpose of adding a lowercase "u" as a modifier after the final delimiter in a Perl-compatible regular expression?

31 / 39

Assuming that $first_name and $family_name are valid strings, which statement is invalid?

32 / 39

What is the job of the controller as a component in MVC?

33 / 39

PHP supports multiple types of loops. If you wanted to loop through a block of code if and as long a specified condition is true, which type of loop would you use?

34 / 39

The following XML document is in books.xml. Which code will output "Historical"?

<books>
    <book>
        <title>A Tale of Two Cities</title>
            <author>Charles Dickens</author>
            <categories>
            <category>Classics</category>
            <category>Historical</category>
            </categories>
            </book>
        <title>Then There Were None</title>
            <author>Agatha Christies</author>
            <categories>
            <category>Mystery</category>
        </categories>
    </book>
</books>

 

35 / 39

Which operator would you use to find the remainder after division?

36 / 39

Which are valid PHP error handling keywords?

37 / 39

What is the best way to explain what this script does?

1 if (!\$\_SESSION['myusername'])
2 {
3 header('locaton: /login.php');
4 exit;
5 }

 

38 / 39

What displays in a browser when the following code is written?

39 / 39

What is a key difference between GET and POST?

Your score is

The average score is 0%

0%

Recommended Articles for you: