Home / Programming Questions / PHP MCQs / Page 3

PHP MCQs with answers Page - 3

Dear candidates you will find MCQ questions of PHP here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

S

Santosh Mishra • 1.61K Points
Master

Q. What will be the output of the following code? 

Code:
<?php
function track() 
{
	static $count = 0;
	$count++;
	echo $count;
}
track();
track();
track();
?>
(A) 123
(B) 111
(C) 000
(D) 011

S

Santosh Mishra • 1.61K Points
Master

Q. What will be the output of the following PHP code?

Code:
<?php
$a = "clue";
$a .= "get";
echo "$a";
?>
(A) get
(B) true
(C) false
(D) clueget

S

Santosh Mishra • 1.61K Points
Master

Q. What will be the output of the following PHP code? 

Code:
<?php
$a = 5;
$b = 5;
span class="sys-fun">echo ($a === $b);
?>
(A) 5 === 5
(B) Error
(C) 1
(D) False

S

Santosh Mishra • 1.61K Points
Master

Q. Which of the below symbols is a newline character?

(A)
(B)
(C) /n
(D) /r

S

Santosh Mishra • 1.61K Points
Master

Q. Which of the conditional statements is/are supported by PHP? 
1. if statements 
2. if-else statements 
3. if-elseif statements 
4. switch statements

(A) Only 1
(B) 1, 2 and 4
(C) 2, 3 and 4
(D) All of the mentioned.

S

Santosh Mishra • 1.61K Points
Master

Q. What will be the output of the following PHP code? 

Code:
<?php
$team = "arsenal";
switch ($team) 
{
case "manu":
  echo "I love man u";
case "arsenal":
  echo "I love arsenal";
case "manc":
  echo "I love manc"; 
}
?>
(A) I love arsenal
(B) Error
(C) I love arsenalI love manc
(D) I love arsenalI love mancI love manu

S

Santosh Mishra • 1.61K Points
Master

Q. Which of the looping statements is/are supported by PHP?
1. for loop
2. while loop
3. do-while loop
4. foreach loop

(A) 1 and 2
(B) 1, 2 and 3
(C) All of the mentioned
(D) None of the mentioned

S

Santosh Mishra • 1.61K Points
Master

Q. What will be the output of the following PHP code? 

Code:
<?php
$user = array("Ashley", "Bale", "Shrek", "Blank");
for ($x=0; $x < count($user); $x++)
{
  if ($user[$x] == "Shrek") continue;
  printf ($user[$x]); 
}
?>
(A) AshleyBale
(B) AshleyBaleBlank
(C) ShrekBlank
(D) Shrek

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.