PHP MCQ Questions and Answers

Practice Mode
Showing 10 of 130 questions
Q121
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.
  • A client side language
  • B local language
  • C global language
  • D loosely typed language
Answer: Option D
Q122
Which of the following is not a valid variable name?
  • A $number-in-class
  • B $nic
  • C $NumberInClass
  • D $number_in_class
Answer: Option A
Q123
Which of the following function is used to change the root directory in PHP?
  • A choot()
  • B change_root()
  • C cd_root()
  • D cd_r()
Answer: Option A
Q124
PHP is
  • A client side script language
  • B server side script language
  • C event-driven language
Answer: Option B
Q125
$father="mother"; $mother="son"; echo $$father; ?>
  • A son
  • B mother
  • C motherson
  • D error
Answer: Option A
Q126
<?php $x=array(4,2,5,1,4,5,3,4); $y=array_count_values($x); echo count($y); ?>
  • A 8
  • B 5
  • C 7
  • D 28
Answer: Option B
Q127
The PHP syntax is most similar to:
  • A PERL and C
  • B Java script
  • C VB Script
  • D Visual Basic
Answer: Option A
Q128
what will be the output of below code ? <?php $arr = array(5 => 1, 12 => 2); $arr[] = 56; $arr["x"] = 42; echo var_dump($arr); ?>
  • A 42
  • B array(3) { [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }
  • C array(4) { [5]=>int(1) [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }
  • D 1,2,56,42
Answer: Option C
Q129
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)); ?>
  • A 2009-5-19:14:31:38
  • B 2009-5-19:2:31:38
  • C 19-5-2009:2:31:38
  • D 19/5/2009:14:31:38
Answer: Option A
Q130
<?php $color=array("red","yellow","white"); $x=in_array("black",$color); if($x==0) echo "good bye"; if($x==1) echo "Hello"; ?>
  • A Hello
  • B Error
  • C good bye
  • D None of the above
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test