Explore topic-wise MCQs in Php.

This section includes 9 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

What will be the output of the following PHP code?
<?php
$url = "interview@mania.com";
echo ltrim(strstr($url, "@"),"@");
?>

A. interview@mania.com
B. interviewmania.com
C. interview.com
D. mania.com
E. None of these
Answer» E. None of these
2.

What will be the output of the following PHP code?
<?php
$contact = "inter0view@mania.com";
$contact = str_replace("0","@",$contact);
echo "Contact to the Interview Mania web designer at $contact.";
?>

A. Error
B. Nothing
C. Contact to the Interview Mania web designer at inter@view@mania.com.
D. Contact to the Interview Mania web designer at inter0view@mania.com.
E. None of these
Answer» D. Contact to the Interview Mania web designer at inter0view@mania.com.
3.

What will be the output of the following PHP code?
<?php
$Message = "this is important message...";
echo ucwords($Message);
?>

A. Error
B. This Is Important Message...
C. Nothing
D. this is important message...
E. None of these
Answer» C. Nothing
4.

What will be the output of the following PHP code?
<?php
echo str_pad("Salad", 10)." is good.";
?>

A. Interview was good.
B. was Interview good
C. good was interview
D. Nothing
E. None of these
Answer» B. was Interview good
5.

What will be the output of the following PHP code?
$cars = array("Datsun", "Jeep", "Lada", "Spyker");
$car = preg_grep("/^L/", $cars);
print_r($car);
?>

A. None of these
Answer» B.
6.

What will be the output of the following PHP code?
$name = "mAnjeSh";
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
E. None of these
Answer» D. Error
7.

Which among the following is/are not a metacharacter?

A. B
B. a
C. A
D. b
E. None of these
Answer» C. A
8.

Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ?

A. fooooool
B. fol
C. fool
D. fooool
E. fool and fooool both
Answer» F.
9.

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

A. PEAR
B. Perl
C. POSIX
D. Pearl
E. Perl and POSIX both
Answer» F.