Sail E0 Webinar

MCQs

Total Questions : 30 | Page 1 of 3 pages
Question 1. Which function is useful when you want to output the executed command's result?
  1.    out_cmm()
  2.    out_system()
  3.    cmm()
  4.    system()
 Discuss Question
Answer: Option D. -> system()


system()


Question 2. Which one of the following function reads a directory into an Array?
  1.    scandir()
  2.    readdir()
  3.    scandirectory()
  4.    readdirectory()
 Discuss Question
Answer: Option A. -> scandir()


It returns an array consisting of files and directories found in directory or returns FALSE on error.


Question 3. Which one of the following is the right way of defining a function in PHP?
  1.    function { function body }
  2.    data type functionName(parameters) { function body }
  3.    functionName(parameters) { function body }
  4.    function fumctionName(parameters) { function body }
 Discuss Question
Answer: Option D. -> function fumctionName(parameters) { function body }


function fumctionName(parameters) { function body }


Question 4. Type Hinting was introduced in which version of PHP?
  1.    PHP 4
  2.    PHP 5
  3.    PHP 5.3
  4.    PHP 6
 Discuss Question
Answer: Option B. -> PHP 5


Type hinting gives you the ability to force parameters to be objects of certain class or to be arrays. PHP 5 introduced this feature.


Question 5. Which of the following PHP functions can be used to get the current memory usage?
  1.    get_usage()
  2.    get_peak_usage()
  3.    get_memory_usage()
  4.    get_memory_peak_usage()
 Discuss Question
Answer: Option C. -> get_memory_usage()


We can use the memory_get_usage() function, and to get the highest amount of memory used at any point, we can use the memory_get_peak_usage() function.


Question 6. What will happen in this function call?
< ?php
function calc($price,$tax)
{
$total = $price + $tax;
}
$pricetag = 15;
$taxtag = 3;
calc($pricetag, $taxtag);
?>
  1.    Call By Value
  2.    Call By Reference
  3.    Default Argument Value
  4.    Type Hinting
 Discuss Question
Answer: Option A. -> Call By Value


When you pass an argument in the above manner or say we pass 15 and 3 directly, it is called passing by value or call by value.


Question 7. What will be the output of the following PHP code?
< ?php
function calc($price, $tax="")
{
$total = $price + ($price * $tax);
echo "$total";
}
calc(42);
?>
  1.    Error
  2.    0
  3.    42
  4.    84
 Discuss Question
Answer: Option C. -> 42


You can designate certain arguments as optional by placing them at the end of the list and assigning them a default value of nothing.


Question 8. What will be the output of the following PHP code?
< ?php
echo lcfirst("welcome to India");
?>
  1.    welcome to India
  2.    welcome to india
  3.    Welcome to India
  4.    Welcome to india
 Discuss Question
Answer: Option A. -> welcome to India


The lcfirst() function converts the first character of a string to lowercase.


Question 9. What will be the output of the following PHP code?
< ?php
echo ucwords("i love my country");
?>
  1.    I love my country
  2.    i love my Country
  3.    I love my Country
  4.    I Love My Country
 Discuss Question
Answer: Option D. -> I Love My Country


The ucwords() function converts the first character of each word in a string to uppercase.


Question 10. Which of the following are valid function names?i) function()ii) €()iii) .function()iv) $function()
  1.    Only (ii)
  2.    None of the mentioned.
  3.    All of the mentioned.
  4.    (iii) and (iv)
 Discuss Question
Answer: Option A. -> Only (ii)


Except a) others are invalid names. According to the specified regular expression ([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*), a function name like this one is valid.


Latest Videos

Latest Test Papers