Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. What will be the output of the following PHP code ?
< ?php
one = 1;
two = 2;
three = 3;
four = 4;
echo "one / two + three / four";
?>
  1.    0.75
  2.    0.25
  3.    1.25
  4.    Error
 Discuss Question
Answer: Option D. -> Error


Variables should start with a $ symbol, since one, two, three, four don't begin with $ symbol we will get an error.


Question 2. What will be the output of the following PHP code ?
< ?php
$on_e = 1;
$tw_o = 2;
$thre_e = 3;
$fou_r = 4;
echo "$on_e / $tw_o + $thre_e / $fou_r" ;
?>
  1.    0.75
  2.    0.05
  3.    1.25
  4.    Error
 Discuss Question
Answer: Option C. -> 1.25


You can use _ in a variable name.


Question 3. What will be the output of the following PHP code ?
< ?php
$on$e = 1;
$tw$o = 2;
$thre$e = 3;
$fou$r = 4;
echo "$on$e / $tw$o + $thre$e / $fou$r" ;
?>
  1.    0.75
  2.    0.05
  3.    1.25
  4.    Error
 Discuss Question
Answer: Option D. -> Error


You can not use the $ in between the variable name.


Question 4. What will be the output of the following PHP code ?
< ?php
echo $red ;
?>
  1.    0
  2.    Nothing
  3.    True
  4.    Error
 Discuss Question
Answer: Option B. -> Nothing


There will no output returned as the variable $red does not hold any value.


Question 5. What will be the output of the following PHP code ?
< ?php
$On_e = 1;
$tw_o = 2;
$thre_e = 3;
$fou_r = 4;
echo "$on_e / $tw_o + $thre_e / $fou_r";
?>
  1.    0.75
  2.    0.05
  3.    1.25
  4.    Error
 Discuss Question
Answer: Option A. -> 0.75


Since the variable initialised is $On_e and the variable in the echo statement is $on_e the echo statement treats $on_e as 0;


Question 6. What will be the output of the following PHP code ?
< ?php
echo "$four4 + $three3 / $two2 - 1";
?>
  1.    4.5
  2.    7
  3.    3.5
  4.    Error
 Discuss Question
Answer: Option A. -> 4.5


You can use numbers in a variable name.


Question 7. What will be the output of the following PHP code ?
< ?php
var $one = 1;
var $two = 2;
echo "$one / $two * $one / $two * $two";
?>
  1.    1
  2.    0
  3.    0.5
  4.    Error
 Discuss Question
Answer: Option D. -> Error


You can not use var before a variable name.


Question 8. What will be the output of the following PHP code ?
< ?php
$4four = 4;
$3three = 3;
$2two = 2;
echo "$4four + $3three / $2two - 1";
?>
  1.    4.5
  2.    7
  3.    3.5
  4.    Error
 Discuss Question
Answer: Option D. -> Error


A variable name can not start with a numeric value.


Question 9. What will be the output of the following PHP code ?
< ?php
$hello = "Hello World";
$bye = "Bye";
echo $hello;"$bye";
?>
  1.    Hello World
  2.    Bye
  3.    Hello worldBye
  4.    Error
 Discuss Question
Answer: Option A. -> Hello World


Since there is a semi-colon in between $hello and $bye, the line ends at $hello. However $bye would have printed if a echo was present before "$bye.


Question 10. What will be the output of the following PHP code ?
< ?php
int $one = 1;
echo "$one";
?>
  1.    0
  2.    1
  3.    $one
  4.    Error
 Discuss Question
Answer: Option D. -> Error


Unlike other programming languages there are no data types in PHP.


Latest Videos

Latest Test Papers