PHP MCQs with answers Page - 2

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 following PHP statements will output Hello World on the screen?
1. echo (“Hello World”);
2. print (“Hello World”);
3. printf (“Hello World”);
4. sprintf (“Hello World”);

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

S

Santosh Mishra • 1.66K Points
Master

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

Code:
<?php
$color = "maroon";
$var = $color[2];
echo "$var";
?>
  • (A) a
  • (B) $var
  • (C) r
  • (D) Error

S

Santosh Mishra • 1.66K Points
Master

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

Code:
<?php
$score = 1234;
$scoreboard = (array) $score;
echo $scoreboard[0];
?>
  • (A) 1
  • (B) Error
  • (C) 1234
  • (D) 2

S

Santosh Mishra • 1.66K Points
Master

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

Code:
<?php
$total = "25 students";
$more = 10;
$total = $total + $more;
echo "$total";
?>
  • (A) Error
  • (B) 35 students
  • (C) 35
  • (D) 25 students

S

Santosh Mishra • 1.66K Points
Master

Q. Which of the below statements is equivalent to $add += $add ?

  • (A) $add = $add
  • (B) $add = $add +$add
  • (C) $add = $add + 1
  • (D) $add = $add + $add + 1

S

Santosh Mishra • 1.66K Points
Master

Q. Which statement will output $x on the screen?

  • (A) echo “$x”;
  • (B) echo “$$x”;
  • (C) echo “/$x”;
  • (D) echo “$x;”;

S

Santosh Mishra • 1.66K 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.66K 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.66K 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.66K Points
Master

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

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

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.