PHP MCQs with answers Page - 9

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
$var = "YELLOW";
$var1 = $var[5];
echo "$var1";
?>
  • (A) Y
  • (B) E
  • (C) L
  • (D) W

A

Admin • 831.35K Points
Coach

Q. Which of the following PHP statements will output Hello interview Mania on the screen?

  • (A) sprintf (“Hello interview Mania ”);
  • (B) echo (“Hello interview Mania ”);
  • (C) print (“Hello interview Mania ”);
  • (D) B and C

A

Admin • 831.35K Points
Coach

Q. Which of following variables can be assigned a value to it?

  • (A) $this
  • (B) $3hello
  • (C) $This
  • (D) None of these

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$n  = "12";
$n1 = "21";
print $n+$n1;
?>
  • (A) 33
  • (B) Error
  • (C) 12+21
  • (D) 12

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$n  = 10;
$n1 = 12;
print $n . "+". $n1;
?>
  • (A) 10
  • (B) 12
  • (C) 10+12
  • (D) 12+10

A

Admin • 831.35K Points
Coach

Q. Which of the following php statement/statements will store 120 in variable n?

  • (A) 120 = $n;
  • (B) int $n= 120;
  • (C) int n= 120;
  • (D) $n= 120;

A

Admin • 831.35K Points
Coach

Q. Which of the following must be installed on your computer so as to run PHP script?

  • (A) PHP
  • (B) Apache
  • (C) IIS
  • (D) A, B and C

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$color1 = "1";
$color2 = "1";
echo "$color1" + "$color2";
?>
  • (A) 11
  • (B) 2
  • (C) 0
  • (D) 1

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$color1 = "red";
$color2 = "1";
$color3 = "grey"
echo "$color1" + "$color2" . "$color3";
?>
  • (A) 1grey
  • (B) grey
  • (C) 0
  • (D) red1grey

A

Admin • 831.35K Points
Coach

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

Code:
<?php
echo "This", "was", "a", "bad", "idea";
?>
  • (A) This, was, a, bad, idea
  • (B) This was a bad idea
  • (C) Thiswasabadidea
  • (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