ExamVeda
Login
Home
21
Which of the below symbols is a newline character?
Discuss
Answer & Solution
Answer: Option B
Solution:
PHP treats \n as newline character.
22
What will be the output of the following PHP code?
<?php
$num = 10;
echo 'What is her age? \n She is $num years old';
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
When a string is enclosed within single quotes both variables and escape sequences will not be interpreted when the string is parsed.
23
Which of the conditional statements is/are supported by PHP? 1. if statements 2. if-else statements 3. if-elseif statements 4. switch statements
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
24
What will be the output of the following PHP 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"; 
}
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
If a break statement isn’t present, all subsequent case blocks will execute until a break statement is located.
25
Which of the looping statements is/are supported by PHP?
1. for loop
2. while loop
3. do-while loop
4. foreach loop
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
26
What will be the output of the following PHP code?
<?php
$user = array("Ashley", "Bale", "Shrek", "Blank");
for ($x=0; $x < count($user); $x++)
{
  if ($user[$x] == "Shrek") continue;
  printf ($user[$x]); 
}
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
The continue statement causes execution of the current loop iteration to end and commence at the beginning of the next iteration.
27
If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
Discuss
Answer & Solution
Answer: Option D
Solution:
?: is known as ternary operator. If condition is true then the part just after the ? is executed else the part after : .
28
What is the value of $a and $b after the function call?
<?php
function doSomething( &$arg ) 
{
  $return = $arg;
  $arg += 1;
  return $return;	
}
$a = 3;
$b = doSomething( $a );
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
$a is 4 and $b is 3. The former because $arg is passed by reference, the latter because the return value of the function is a copy of the initial value of the argument.
29
Who is the father of PHP?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
30
How does the identity operator === compare two values?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board