PHP MCQs with answers Page - 13

Here, you will find a collection of MCQ questions on PHP. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 831.35K Points
Coach

Q. In the following PHP program, what is/are the properties?

Code:
<?php
    class Example 
    {
        public $name;
        function Sample()
        {
            echo "Learn PHP";
        }
    } 
?>
  • (A) function sample()
  • (B) echo “This is an example”;
  • (C) public $name;
  • (D) class Example

A

Admin • 831.35K Points
Coach

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

Code:
<?php
define("GREETING", "PHP is a scripting language");
echo $GREETING;
?>
  • (A) $GREETING
  • (B) no output
  • (C) PHP is a scripting language
  • (D) GREETING

A

Admin • 831.35K Points
Coach

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

Code:
<?php
print "echo hello world";
?>
  • (A) echo hello world
  • (B) hello world
  • (C) nothing
  • (D) error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$one = 1;
print($one);
print $one;
?>
  • (A) 01
  • (B) 11
  • (C) 10
  • (D) Error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$cars = array("Volvo", "BMW", "Toyota");
print $cars[2];
?>
  • (A) Volvo
  • (B) BMW
  • (C) Toyota
  • (D) Error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$one = "one";
$two = "two";
print($one$two);
?>
  • (A) onetwo
  • (B) nothing
  • (C) one
  • (D) error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$one = "one";
$two = "two";
print($one,$two);
?>
  • (A) onetwo
  • (B) one, two
  • (C) one
  • (D) error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$one = "one";
$two = "two";
print("$one$two");
?>
  • (A) onetwo
  • (B) $one$two
  • (C) one
  • (D) error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$one = "one";
$two = "two";
print($one==$two);
?>
  • (A) true
  • (B) false
  • (C) nothing
  • (D) error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$one = "one";
$two = "one";
print($one == $two);
?>
  • (A) true
  • (B) false
  • (C) 1
  • (D) error

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ