Explore topic-wise MCQs in Php.

This section includes 20 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
$num = array ("Zero","One", "Two", "Three", "Four","Five");
$subset = array_slice ($num, 2);
print_r ($subset);
?>

A. None of these
Answer» E.
2.

What will be the output of the following PHP code?
<?php
$str = array ("Rahul", "Ajit", "Aju", "Ats");
sort($str);
print_r($str);
?>

A. None of these
Answer» D.
3.

What will be the output of the following PHP code?
<?php
$n = array ("16", "Interview Mania", 10, "4");
echo (array_sum ($n));
?>

A. 16
B. 10
C. 30
D. Interview Mania
E. 4
Answer» D. Interview Mania
4.

What will be the output of the following PHP code?
<?php
$City1 = array ("Noida", "Delhi", "Chennai", "Greenville", "Branford");
$City2 = array ("Chennai", "Derby", "Enfield", "Delhi", "Greenville");
$inter = array_intersect ($City1, $City2);
print_r ($inter);
?>

A. None of these
Answer» E.
5.

What will be the output of the following PHP code?
<?php
$num = array ("2","3","4", "5", "6", "7", "8", "9", "10");
$face = array ("A", "J", "Q", "K");
$cards = array_merge ($face, $num);
print_r ($cards);
?>

A. None of these
Answer» C.
6.

What will be the output of the following PHP code?
<?php
$num = array ("Zero","One", "Two", "Three", "Four","Five");
$subset = array_splice ($num, 3);
print_r ($subset);
?>

A. Error
B. Nothing
C. None of these
Answer» B. Nothing
7.

What will be the output of the following PHP code?
<?php
$Name = array ("Neha", "Ajit", "Rahul", "Ats");
$Name = array_flip($Name);
echo ($Name[0]);
?>

A. Error
B. Nothing
C. Neha
D. Rahul
E. None of these
Answer» B. Nothing
8.

What will be the output of the following PHP code ?
<?php
$name = array("Abhay", "Sujit");
array_push($name, "Neha", "Reema");
print_r($name);
?>

A. None of these
Answer» B.
9.

What will be the output of the following PHP code ?
<?php
$num = range(0, 6);
print_r ($num);
?>

A. None of these
Answer» B.
10.

What will be the output of the following PHP code ?
<?php
$Student = array("Ajit", "Rahul", "Ats", "Aju");
echo pos($Student);
?>

A. Ajit
B. Rahul
C. Ats
D. Aju
E. None of these
Answer» B. Rahul
11.

What will be the output of the following PHP code ?
<?php
$Car = array("J" => "Jaguar", "L" => "Land Rover", "A" => "Audi", "M" => "Maseratti");
echo array_search("Maseratti", $Car);
?>

A. J
B. L
C. A
D. M
E. None of these
Answer» E. None of these
12.

What will be the output of the following PHP code?
<?php
$First = array("Ajit", "Rahul");
$Second = array("Ats", "Aju");
$Third = array_merge($First, $Second);
$Fourth = array("001", "002", "003", "004");
$Result = array_combine($Fourth, $Third);
print_r($Result);
?>

A. Error
B. Nothing
C. None of these
Answer» B. Nothing
13.

What will be the output of the following PHP code?
<?php
$First = array("001" => "Ajit", "002" => "Rahul", "003" => "Ats", "004" => "Aju");
$Second = array("005" => "Ajit", "006" => "Rahul", "007" => "Ats", "008" => "Sujit");
$Third = array("009" => "Sujit");
$Forth = array_merge($Second, $Third);
$Result = array_diff($First, $Forth);
print_r($Result);
?>

A. Error
B. Nothing
C. None of these
Answer» C. None of these
14.

What will be the output of the following PHP code?
<?php
$Country = array("INDIA", "USA", "ENGLAND");
array_pop($Country);
$Country1 = array("ISRAEL");
$Country = array_merge($Country, $Country1);
print_r($Country);
?>

A. Nothing
B. Error
C. None of these
Answer» C. None of these
15.

What will be the output of the following PHP code ?
<?php
$Color = array("R" => "Red", "G" => "Green", "B" => "Blue", "Y" => "Yellow");
$Result = array_flip($Color);
print_r($Result);
?>

A. Error
B. Nothing
C. None of these
Answer» B. Nothing
16.

What will be the output of the following PHP code?
<?php
$First = array_fill(1, 4, "Interview");
$Second = array_fill(5, 1, "Mania");
$Third = array_merge($First, $Second);
print_r($Third);
echo " n";
print_r($Second);
?>

A. None of these
Answer» E.
17.

What will be the output of the following PHP code ?
<?php
$Student = array("Ajit" => "23", "Rahul" => "22","Ats" => "23");
array_pop($Student);
print_r(array_change_key_case($Student, CASE_UPPER));
?>

A. Error
B. Nothing
C. None of these
Answer» E.
18.

What will be the output of the following PHP code?
<?php
$First = array("001" => "Ajit", "002" => "Ats", "003" => "Aju");
echo array_shift($First);
echo " n";
array_pop($First);
print_r($First);
?>

A. Error
B. Nothing
C. None of these
Answer» B. Nothing
19.

What will be the output of the following PHP code?
<?php
$First = array("Rahul","Ajit","Ats","Rahul","Ats","Sujit");
$Second = array("Rahul","Rahul","Ajit","Rahul","Aju","Sujit");
$Third = array_combine($First,$Second);
print_r(array_count_values($Third));
?>

A. Error
B. Nothing
C. None of these
Answer» D.
20.

Which of the following function should be used, to sort the array in case?

A. natcasesort()
B. naturalsort()
C. casesort()
D. dsort()
E. None of these
Answer» B. naturalsort()