PHP MCQs with answers Page - 17

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. Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ?

  • (A) fooool
  • (B) fol
  • (C) fool
  • (D) fool and fooool both

A

Admin • 831.35K Points
Coach

Q. POSIX stands for

  • (A) Portative Operating System Interface for Unix
  • (B) Portative Operating System Interface for Linux
  • (C) Portable Operating System Interface for Linux
  • (D) Portable Operating System Interface for Unix

A

Admin • 831.35K Points
Coach

Q. POSIX implementation was deprecated in which version of PHP?

  • (A) PHP 5.3
  • (B) PHP 5.2
  • (C) PHP 5
  • (D) PHP 4

A

Admin • 831.35K Points
Coach

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

Code:
$name = "ruCHiSharma";
if (ereg("([^a-z])",$name))
echo "Name must be all lowercase!";
else
echo "Name is all lowercase!";
?>
  • (A) Name is all lowercase!
  • (B) No Output is returned
  • (C) Name must be all lowercase!
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. How many functions does PHP offer for searching strings using POSIX style regular expression?

  • (A) 10
  • (B) 9
  • (C) 8
  • (D) 7

A

Admin • 831.35K Points
Coach

Q. [:alpha:] can also be specified as.

  • (A) [A-z].
  • (B) [A-Za-z0-9].
  • (C) [a-z].
  • (D) [A-za-z].

A

Admin • 831.35K Points
Coach

Q. Which one of the following regular expression matches any string containing zero or one p?

  • (A) p*
  • (B) p+
  • (C) p#
  • (D) P?

A

Admin • 831.35K Points
Coach

Q. PHP has long supported two regular expression implementations known as _______ and _______.

  • (A) PEAR
  • (B) Perl
  • (C) POSIX
  • (D) Perl and POSIX both

A

Admin • 831.35K Points
Coach

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

Code:
<?php
define("STR_VAR","Ravinder"); 
${STR_VAR} = "Singh"; 
echo STR_VAR;
echo ${STR_VAR}; 
?>
  • (A) Ravinder
  • (B) RavinderSingh
  • (C) Error
  • (D) Singh

A

Admin • 831.35K Points
Coach

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

Code:
<?php
define("FIRST_NAME", "Ajit");
define("LAST_NAME", FIRST_NAME);
 
echo FIRST_NAME;
echo LAST_NAME; 
?>
  • (A) Nothing
  • (B) Ajit
  • (C) FIRST_NAME LAST_NAME
  • (D) AjitAjit

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