Sail E0 Webinar

MCQs

Total Questions : 26 | Page 3 of 3 pages
Question 21. Which of the following must be installed on your computer so as to run PHP script?i) Adobe Dreamweaverii) PHPiii) Apacheiv) IIS
  1.    All of the mentioned
  2.    Only (ii)
  3.    (ii) and (iii)
  4.    (ii), (iii) and (iv)
 Discuss Question
Answer: Option D. -> (ii), (iii) and (iv)


To run PHP code you need to have PHP and a web server, both IIS and Apache are web servers.You can choose either one according to your platform.


Question 22. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
  1.    12
  2.    1
  3.    Error
  4.    5
 Discuss Question
Answer: Option D. -> 5


?: is known as ternary operator. If condition is true then the part just after the ? is executed else the part after : .


Question 23. What will be the output of the following PHP code?
< ?php
$total = "25 students";
$more = 10;
$total = $total + $more;
echo "$total" ;
?>
  1.    Error
  2.    35 students
  3.    35
  4.    25 students
 Discuss Question
Answer: Option C. -> 35


The integer value at the beginning of the original $total string is used in the calculation. However if it begins with anything but a numerical value, the value will be 0.


Question 24. What will be the output of the following PHP code?
< ?php
$color = "maroon";
$var = $color[2];
echo "$var" ;
?>
  1.    a
  2.    Error
  3.    $var
  4.    r
 Discuss Question
Answer: Option D. -> r


PHP treats strings in the same fashion as arrays, allowing for specific characters to be accessed via array offset notation.


Question 25. Which of the following PHP statements will output Hello World on the screen?(i) echo ("Hello World);(ii) print ("Hello World);(iii) printf ("Hello World);(iv) sprintf ("Hello World);
  1.    (i) and (ii)
  2.    (i), (ii) and (iii)
  3.    All of the mentioned
  4.    (i), (ii) and (iv)
 Discuss Question
Answer: Option B. -> (i), (ii) and (iii)


echo(), print() and printf() all three can be used to output a statement onto the screen. The sprintf() statement is functionally identical to printf() except that the output is assigned to a string rather than rendered to the browser.


Question 26. What will be the output of the following PHP code?
< ?php
$score = 1234;
$scoreboard = (array) $score;
echo $scoreboard[0];
?>
  1.    1
  2.    Error
  3.    1234
  4.    2
 Discuss Question
Answer: Option C. -> 1234


The (array) is a cast operator which is used for converting values from other data types to array.


Latest Videos

Latest Test Papers