PHP MCQs with answers Page - 6

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 • 832.27K Points
Coach

Q. As the namespace size grows, using namespaces can become a little repetitious, but PHP also provides the . . . . . statement, which allows you to alias a specific namespace.

  • (A) php
  • (B) grant
  • (C) use
  • (D) label

A

Admin • 832.27K Points
Coach

Q. Some PHP code might not have a namespace and therefore lives in the . . . . . . namespace.

  • (A) Default
  • (B) Global
  • (C) PRE
  • (D) Automatic

A

Admin • 832.27K Points
Coach

Q. The value of __NAMESPACE__ is a string that contains the current namespace name. In global, un-namespaced code, it contains . . . . . .

  • (A) NULL
  • (B) 0
  • (C) an empty string
  • (D) gibberish value

A

Admin • 832.27K Points
Coach

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

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

A

Admin • 832.27K Points
Coach

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

Code:
<?php
$color = "red";
echo "$color";
echo "$COLOR";
echo "$Color";
?>
  • (A) redredred
  • (B) redred
  • (C) red
  • (D) Error

A

Admin • 832.27K Points
Coach

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

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

A

Admin • 832.27K Points
Coach

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

Code:
<?php
echo "Hello World"
?>
  • (A) Hello world
  • (B) Hello world in italics
  • (C) Nothing
  • (D) Error

A

Admin • 832.27K Points
Coach

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

Code:
<?php
echo "echo "Hello World"";
?>
  • (A) Hello world
  • (B) echo “Hello world”
  • (C) echo Hello world
  • (D) Error

A

Admin • 832.27K Points
Coach

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

Code:
<?php
<?php
echo "Hello world";
?>
?>
  • (A) Hello
  • (B) Hello world
  • (C) Nothing
  • (D) Error

A

Admin • 832.27K Points
Coach

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

Code:
<?php
$color = red;
echo "$color";
?>
  • (A) red
  • (B) $color
  • (C) red
  • (D) Error