PHP MCQ Questions and Answers
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
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
122. Which of the following is not a valid variable name?
- $number-in-class
- $nic
- $NumberInClass
- $number_in_class
123. Which of the following function is used to change the root directory in PHP?
- choot()
- change_root()
- cd_root()
- cd_r()
124. PHP is
- client side script language
- server side script language
- event-driven language
125. $father="mother"; $mother="son"; echo $$father; ?>
- son
- mother
- motherson
- error
126. <?php $x=array(4,2,5,1,4,5,3,4); $y=array_count_values($x); echo count($y); ?>
- 8
- 5
- 7
- 28
127. The PHP syntax is most similar to:
- PERL and C
- Java script
- VB Script
- Visual Basic
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
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
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