Sail E0 Webinar

MCQs

Total Questions : 30 | Page 2 of 3 pages
Question 11. What will be the output of the following PHP code?
< ?php
function a()
{
function b()
{
echo 'I am b';
}
echo 'I am a';
}
b();
a();
?>
  1.    I am b
  2.    I am bI am a
  3.    Error.
  4.    I am a Error
 Discuss Question
Answer: Option C. -> Error.


This will be the output- Fatal error: Call to undefined function b(). You cannot call a function which is inside a function without calling the outside function.


Question 12. What will be the output of the following PHP code?
< ?php
function a()
{
function b()
{
echo 'I am b';
}
echo 'I am a';
}
a();
a();
?>
  1.    I am b
  2.    I am bI am a
  3.    Error
  4.    I am a Error
 Discuss Question
Answer: Option D. -> I am a Error


This will be the output- I am a Fatal error: Cannot redeclare b()


Question 13. What will be the output of the following PHP code?
< ?php
$op2 = "blabla";
function foo($op1)
{
echo $op1;
echo $op2;
}
foo("hello");
?>
  1.    helloblabla
  2.    Error
  3.    hello
  4.    helloblablablabla
 Discuss Question
Answer: Option C. -> hello


If u want to put some variables in function that was not passed by it, you must use "global. Inside the function type global $op2.


Question 14. What will be the output of the following PHP code?
< ?php
function foo($msg)
{
echo "$msg";
}
$var1 = "foo";
$var1("will this work");
?>
  1.    Error.
  2.    $msg
  3.    0
  4.    will this work
 Discuss Question
Answer: Option D. -> will this work


It is possible to call a function using a variable which stores the function name.


Question 15. A function in PHP which starts with __ (double underscore) is know as..
  1.    Magic Function
  2.    Inbuilt Function
  3.    Default Function
  4.    User Defined Function
 Discuss Question
Answer: Option A. -> Magic Function


PHP functions that start with a double underscore “ a "__ “ are called magic functions in PHP. They are functions that are always defined inside classes, and are not stand-alone functions.


Question 16. Which one of the following PHP functions can be used to build a function that accepts any number of arguments?
  1.    func_get_argv()
  2.    func_get_argc()
  3.    get_argv()
  4.    get_argc()
 Discuss Question
Answer: Option B. -> func_get_argc()


func_get_argc()


Question 17. Which one of the following PHP functions can be used to find files?
  1.    glob()
  2.    file()
  3.    fold()
  4.    get_file()
 Discuss Question
Answer: Option A. -> glob()


glob()


Question 18. Which one of the following PHP function is used to determine a file's last access time?
  1.    fileltime()
  2.    filectime()
  3.    fileatime()
  4.    filetime()
 Discuss Question
Answer: Option C. -> fileatime()


The fileatime() function returns a file's last access time in Unix timestamp format or FALSE on error.


Question 19. Which one of the following function is capable of reading a file into an array?
  1.    file()
  2.    arrfile()
  3.    arr_file()
  4.    file_arr()
 Discuss Question
Answer: Option A. -> file()


file()


Question 20. The filesize() function returns the file size in ___.
  1.    bits
  2.    bytes
  3.    kilobytes
  4.    gigabytes
 Discuss Question
Answer: Option B. -> bytes


bytes


Latest Videos

Latest Test Papers