PHP MCQs with answers Page - 4

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.01K Points
Coach

Q. Variables always start with a ........ in PHP

  • (A) Pond-sign
  • (B) Yen-sign
  • (C) Dollar-sign
  • (D) Euro-sign

A

Admin • 832.01K Points
Coach

Q. Which of the following is not valid PHP code?

  • (A) $_10
  • (B) ${“MyVar”}
  • (C) &$something
  • (D) $10_somethings

A

Admin • 832.01K Points
Coach

Q. You can test the type of any variable with the ..... function.

  • (A) whattype()
  • (B) showtype()
  • (C) gettype()
  • (D) settype()

A

Admin • 832.01K Points
Coach

Q. If you echo a Boolean variable, the value FALSE displays as a .... and the value TRUE echoes as a .....

  • (A) 0, 1
  • (B) blank string, 2
  • (C) empty variable, 1
  • (D) blank string, 1

A

Admin • 832.01K Points
Coach

Q. String values must be enclosed in ......

  • (A) single quotes
  • (B) double quotes
  • (C) both A and B
  • (D) none of above

A

Admin • 832.01K Points
Coach

Q. PHP ..... demand that you declare a data type when you create a variable.

  • (A) does
  • (B) does not
  • (C) ---
  • (D) ---

A

Admin • 832.01K Points
Coach

Q. strval()

  • (A) Accepts a value and converts it into a string array
  • (B) None of above
  • (C) Accepts a value and converts it into an string dictionary
  • (D) Accepts a value and converts it into string equivalent

A

Admin • 832.01K Points
Coach

Q. What is the limit of a PHP integer value?

  • (A) 16384
  • (B) 65536
  • (C) 1048576
  • (D) 2147483647

A

Admin • 832.01K Points
Coach

Q. PHP considers the following values as False

  • (A) the integer 0
  • (B) the one-character string 0
  • (C) constant NULL
  • (D) All of the above

A

Admin • 832.01K Points
Coach

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

Code:
<?php
function start($string)
{
    if ($string < 45)
        return 20;
    else
        return 40;
}
$t = start(90);
if ($t < 20)
{
    echo "Have a good day!";
}
else
{
    echo "Have a good night!";
}
?>
  • (A) ERROR
  • (B) Have a good day!
  • (C) Have a good night!
  • (D) None of the mentioned