PHP MCQs with answers Page - 16

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
$url = "ruchi@sharma.com";
echo ltrim(strstr($url, "@"),"@");
?>
  • (A) ruchi@sharma.com
  • (B) ruchisharma.com
  • (C) ruchi.com
  • (D) sharma.com

A

Admin • 831.35K Points
Coach

Q. Which one of the following functions finds the last occurrence of a string, returning its numerical position?

  • (A) strrpos()
  • (B) strlast()
  • (C) strlastpos()
  • (D) strpos()

A

Admin • 831.35K Points
Coach

Q. Which one of the following functions can be used to concatenate array elements to form a single delimited string?

  • (A) concat()
  • (B) concatenate()
  • (C) explode()
  • (D) implode()

A

Admin • 831.35K Points
Coach

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

Code:
<?php
$Message = "this is important message...";
echo ucwords($Message);
?>
  • (A) Error
  • (B) This Is Important Message...
  • (C) Nothing
  • (D) this is important message...

A

Admin • 831.35K Points
Coach

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

Code:
<?php
echo str_pad("Salad", 10)." is good.";
?>
  • (A) Interview was good.
  • (B) was Interview good
  • (C) good was interview
  • (D) Nothing

A

Admin • 831.35K Points
Coach

Q. Which one of the following functions will convert a string to all uppercase?

  • (A) struppercase()
  • (B) str_uppercase()
  • (C) uppercase()
  • (D) strtoupper()

A

Admin • 831.35K Points
Coach

Q. Say we have two compare two strings which of the following function/functions can you use?

  • (A) strcspn()
  • (B) strcmp()
  • (C) strcasecmp()
  • (D) All of above

A

Admin • 831.35K Points
Coach

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

Code:
$cars = array("Datsun", "Jeep", "Lada", "Spyker");
$car = preg_grep("/^L/", $cars);
print_r($car);
?>
  • (A) Array ( [2] => Lada )
  • (B) Array ( [1] => Jeep )
  • (C) Array ( [0] => Datsun )
  • (D) Array ( [3] => Spyker )

A

Admin • 831.35K Points
Coach

Q. How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.

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

A

Admin • 831.35K Points
Coach

Q. Which among the following is/are not a metacharacter?

  • (A) B
  • (B) a
  • (C) A
  • (D) 

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