PHP MCQs with answers Page - 18

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
define("__LINE__", "She is beautiful");
echo "
";
echo __LINE__;
?>
  • (A) She is beautiful
  • (B) Error
  • (C) Nothing
  • (D) 4

A

Admin • 831.35K Points
Coach

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

Code:
<?php
define("ATTENTION", "MCQ Buddy is good website.", true);
echo $ATTENTION;
?>
  • (A) MCQ Buddy is good website.
  • (B) Error
  • (C) $ATTENTION
  • (D) ATTENTION

A

Admin • 831.35K Points
Coach

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

Code:
<?php
define("ATTENTION", "MCQ Buddy is good website..", true);
echo ATTENTION;
echo "
";
echo ATTENTION;?>
  • (A) Error
  • (B) MCQ Buddy is good website.
  • (C) MCQ Buddy is good website. MCQ Buddy is good website.
  • (D) Nothing

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$n = 0x6db7;
print $n<<8;
?>
  • (A) Error
  • (B) 0
  • (C) 7190272
  • (D) 0x6db7

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$m = 10;
$n = 11;
$s = 12;
print (( +  + $m + $n) >! ($n - $s));
?>
  • (A) 1
  • (B) 10
  • (C) 11
  • (D) 12

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$m = 10; $n = 11; $s = 12;
print !(( +  + $m + $n) > ($n - $s));
?>
  • (A) 0
  • (B) 1
  • (C) Nothing
  • (D) Error

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$m = 10; $n = 11; $s = 12;
print !(($m + $s) < ($n - $s));
?>
  • (A) Error
  • (B) 1
  • (C) Nothing
  • (D) 0

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$n1 = 13;
print ++$n++;
?>
  • (A) Error
  • (B) Nothing
  • (C) 13
  • (D) 14

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$n1 = 5;
print $n = ++$n;
?>
  • (A) 5
  • (B) 3
  • (C) 1
  • (D) 0

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$p = 6; $q = -8; $r = 2; 
$s = ++$p && ++$q || ++$r;
echo $s;
echo $p;
?>
  • (A) 17
  • (B) 6
  • (C) -8
  • (D) 2

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