PHP MCQ Questions and Answers

Take Exam

PHP MCQ Questions with Answers help candidates strengthen their programming fundamentals and web development logic through objective-style practice. These PHP programming questions and answers are essential for cracking technical interviews and online coding assessments conducted by top recruiters like TCS, Infosys, Cognizant, and Wipro. Each question tests key PHP concepts such as syntax, data types, arrays, functions, form handling, and error management. Practicing these programming MCQs not only enhances problem-solving speed but also builds confidence for real-time technical evaluations. Whether you are preparing for placement drives, semester exams, or web development roles, this PHP MCQ collection with explanations and solutions PDF will help you master PHP efficiently. Begin your programming test practice online now and ace your upcoming PHP interview round.

PHP MCQ

Showing 10 of 130 questions

121. PHP is a _____ . It means you do not have to tell PHP which data type the variable is.PHP automatically converts the variable to the correct data type, depending on its value.

  • client side language
  • local language
  • global language
  • loosely typed language
Show Answer Report

122. Which of the following is not a valid variable name?

  • $number-in-class
  • $nic
  • $NumberInClass
  • $number_in_class
Show Answer Report

123. Which of the following function is used to change the root directory in PHP?

  • choot()
  • change_root()
  • cd_root()
  • cd_r()
Show Answer Report

124. PHP is

  • client side script language
  • server side script language
  • event-driven language
Show Answer Report

125. $father="mother"; $mother="son"; echo $$father; ?>

  • son
  • mother
  • motherson
  • error
Show Answer Report

126. <?php $x=array(4,2,5,1,4,5,3,4); $y=array_count_values($x); echo count($y); ?>

  • 8
  • 5
  • 7
  • 28
Show Answer Report

127. The PHP syntax is most similar to:

  • PERL and C
  • Java script
  • VB Script
  • Visual Basic
Show Answer Report

128. what will be the output of below code ? <?php $arr = array(5 => 1, 12 => 2); $arr[] = 56; $arr["x"] = 42; echo var_dump($arr); ?>

  • 42
  • array(3) { [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }
  • array(4) { [5]=>int(1) [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }
  • 1,2,56,42
Show Answer Report

129. what will the ouptut of below date() function ? <?php $date="2009-5-19"; $time="14:31:38"; $datetime=$date.$time; echo date("Y-m-d:H:i:s",strtotime($datetime)); ?>

  • 2009-5-19:14:31:38
  • 2009-5-19:2:31:38
  • 19-5-2009:2:31:38
  • 19/5/2009:14:31:38
Show Answer Report

130. <?php $color=array("red","yellow","white"); $x=in_array("black",$color); if($x==0) echo "good bye"; if($x==1) echo "Hello"; ?>

  • Hello
  • Error
  • good bye
  • None of the above
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test