πŸ“Š PHP
Q. What will be the output of the following PHP code?
Code:
<?php
$user = array("Ats ", "Ajit ", "Rahul ", "Aju ");
for ($str=0; $str < count($user); $str++)	{
if ($user[$str] == "Rahul ") continue;
printf ($user[$str]); 
}
?>
  • (A) Error
  • (B) Rahul
  • (C) Ats Ajit Aju
  • (D) Ats Ajit Rahul Aju
πŸ’¬ Discuss
βœ… Correct Answer: (C) Ats Ajit Aju

Explanation: When the mentioned for loop executes, it will start printing all the strings in the array. But when it sees that the if condition is true, it doesn't print the string and just skip the code below it and start with next value.
So it will print "Ats Ajit Aju " only.

πŸ“Š PHP
Q. Which of the looping statements is/are supported by PHP?
  • (A) for each loop
  • (B) do-while loop
  • (C) while loop
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
πŸ“Š PHP
Q. What will be the output of the following PHP code?
Code:
<?php
$State = "Chennai";
switch ($State) {
case "Mumbai":
echo "I love Mumbai. ";
case "Chennai":
echo "I love Chennai. ";
case "Rajshathan":
echo "I love Rajshatan. "; }
?>
  • (A) I love Chennai. I love Mumbai.
  • (B) I love Mumbai.
  • (C) Error
  • (D) I love Chennai. I love Rajshatan.
πŸ’¬ Discuss
βœ… Correct Answer: (D) I love Chennai. I love Rajshatan.
πŸ“Š PHP
Q. Which of the conditional statements is/are supported by PHP?
  • (A) switch statements
  • (B) if-elseif statements
  • (C) if statements
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
πŸ“Š PHP
Q. Which of the below symbols is a newline character?
  • (A) \r
  • (B) \n
  • (C) /n
  • (D) /r
πŸ’¬ Discuss
βœ… Correct Answer: (B) \n
πŸ“Š PHP
Q. What will be the output of the following PHP code?
Code:
<?php
$num = 6;
$num1 = 6;
echo ($num === $num1);
?>
  • (A) Error
  • (B) 1
  • (C) False
  • (D) 6 === 6
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1
πŸ“Š PHP
Q. What will be the output of the following PHP code?
Code:
<?php
$str = "MCQ";
$str .= "Buddy";
echo "$str";
?>
  • (A) MCQ
  • (B) Error
  • (C) Buddy
  • (D) MCQBuddy
πŸ’¬ Discuss
βœ… Correct Answer: (D) MCQBuddy
πŸ“Š PHP
Q. What will be the output of the following code?
Code:
<?php
function track() 
  {
    static $var = 0;
    $var++;
    echo $var;
  }
    track();
    track();
    track();
?>
  • (A) 000
  • (B) 010
  • (C) 110
  • (D) 123
πŸ’¬ Discuss
βœ… Correct Answer: (D) 123
πŸ“Š PHP
Q. Which statement will output $x on the screen?
  • (A) echo β€œ$x;”;
  • (B) echo β€œ/$x”;
  • (C) echo β€œ$$x”;
  • (D) echo β€œ$x”;
πŸ’¬ Discuss
βœ… Correct Answer: (D) echo β€œ$x”;
πŸ“Š PHP
Q. Which of the below statements is equivalent to $sum+= $sum ?
  • (A) $sum= $sum+$sum
  • (B) $sum= $sum
  • (C) $sum= $sum+ $sum+ 1
  • (D) $sum= $sum+ 1
πŸ’¬ Discuss
βœ… Correct Answer: (A) $sum= $sum+$sum