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.66K 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.66K 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.66K 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.66K 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

S

Santosh Mishra • 1.66K Points
Master

Q. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

  • (A) 12
  • (B) 1
  • (C) Error
  • (D) 5

S

Santosh Mishra • 1.66K Points
Master

Q. What is the value of $a and $b after the function call?

Code:
<?php
function doSomething( &$arg ) 
{
  $return = $arg;
  $arg += 1;
  return $return;	
}
$a = 3;
$b = doSomething( $a );
?>
  • (A) a is 3 and b is 4
  • (B) a is 4 and b is 3
  • (C) Both are 3
  • (D) Both are 4

S

Santosh Mishra • 1.66K Points
Master

Q. Who is the father of PHP?

  • (A) Rasmus Lerdorf
  • (B) Willam Makepiece
  • (C) Drek Kolkevi
  • (D) List Barely

S

Santosh Mishra • 1.66K Points
Master

Q. How does the identity operator === compare two values?

  • (A) It converts them to a common compatible data type and then compares the resulting values
  • (B) It returns True only if they are both of the same type and value
  • (C) If the two values are strings, it performs a lexical comparison
  • (D) It bases its comparison on the C strcmp function exclusively

Y

Yogesh • 7.43K Points
Tutor III

Q. What should be the correct syntax to write a PHP code?

  • (A) < php >
  • (B) < ? php ?>
  • (C)
  • (D)

Y

Yogesh • 7.43K Points
Tutor III

Q. Under what circumstance is it impossible to assign a default value to a parameter while declaring a function?

  • (A) When the parameter is Boolean
  • (B) When the function is being declared as a member of a class
  • (C) When the parameter is being declared as passed by reference
  • (D) When the function contains only one parameter

Be the first to start discuss.

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.

Image

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.