PHP MCQs with answers Page - 12

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. What will be the output of the following PHP code ?

Code:
<?php
 # echo "Hello MCQ Buddy";
 echo "# Hello MCQ Buddy"; 
?>
  • (A) Hello MCQ Buddy
  • (B) Error
  • (C) Hello MCQ Buddy # Hello MCQ Buddy
  • (D) # Hello MCQ Buddy

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$country = "India";
echo "$country";
echo "$COUNTRY";
echo "$Country";
?
  • (A) Error
  • (B) India
  • (C) IndiaIndiaIndia
  • (D) IndiaIndia

A

Admin • 831.35K Points
Coach

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

Code:
<?php
Echo "Hello
";
echo "MCQ
";
ECHO "Buddy";
?>
  • (A) Hello
  • (B) MCQ
  • (C) Buddy
  • (D) Hello MCQ Buddy

A

Admin • 831.35K Points
Coach

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

Code:
<?php
print_r "Hello MCQ Buddy"
?>
  • (A) Hello MCQ Buddy
  • (B) Missing semicolon error
  • (C) Error
  • (D) Nothing

A

Admin • 831.35K Points
Coach

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

Code:
<?php
"Hello MCQ Buddy"
?>
  • (A) Nothing
  • (B) Hello MCQ Buddy
  • (C) Missing semicolon error
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. How to define a function in PHP?

  • (A) functionName(parameters) {function body}
  • (B) function {function body}
  • (C) function functionName(parameters) {function body}
  • (D) data type functionName(parameters) {function body}

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$x = 10;
$y = 20;
if ($x > $y && 1||1)
    print "PHP MCQ" ;
else
    print "Welcome to MCQ Buddy";
?>
  • (A) no output
  • (B) Welcome to MCQ Buddy
  • (C) PHP MCQ
  • (D) error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$fruits = array ("apple", "orange", array ("pear", "mango"),"banana");
echo (count($fruits, 1));
?>
  • (A) 6
  • (B) 5
  • (C) 4
  • (D) 3

A

Admin • 831.35K Points
Coach

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

Code:
<?php
    function multi($num)
    {
        if ($num == 3)
            echo "I Wonder";
        if ($num == 7)
            echo "Which One";
        if ($num == 8)
            echo "Is The";
        if ($num == 19)
            echo "Correct Answer";
    }
    $can = stripos("I love php, I love php too!","PHP");
    multi($can);
?>
  • (A) Correct Answer
  • (B) Is The
  • (C) I Wonder
  • (D) Which One

A

Admin • 831.35K Points
Coach

Q. Which of the following PHP functions can be used for generating unique ids?

  • (A) md5()
  • (B) uniqueid()
  • (C) mdid()
  • (D) id()

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