PHP Functions MCQs
PHP Functions MCQs : This section focuses on "Functions" in PHP. These Multiple Choice Questions (mcq) should be practiced to improve the PHP skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. How many types of functions are available in php?
A. 5
B. 4
C. 3
D. 2
View Answer
Ans : D
Explanation: PHP provides us with two major types of functions Built-in functions and User Defined Functions.
2. Which of the following is not a built-in function in php ?
A. print_r()
B. fopen()
C. fclosed()
D. gettype()
View Answer
Ans : C
Explanation: fclosed() is not a built-in function in php.
3. Why should we use functions?
A. Reusability
B. Easier error detection
C. Easily maintained
D. All of the above
View Answer
Ans : D
Explanation: we use functions beacause it provide Reusability, Easier error detection, Easily maintained.
4. A function name always begins with the keyword _________.
A. fun
B. def
C. function
D. None of the above
View Answer
Ans : C
Explanation: A function name always begins with the keyword function.
5. A function name cannot start with a ____
A. alphabet
B. underscore
C. number
D. Both C and B
View Answer
Ans : C
Explanation: A function name cannot start with a number. It can start with an alphabet or underscore.
6. A function name is not case-sensitive?
A. True
B. False
C. Only user-defined function is case-sensitive
D. None of the above
View Answer
Ans : A
Explanation: A function name is not case-sensitive, the following statement is true.
7. A function name is not case-sensitive?
<?php
function funclfc()
{
echo "This is letsfindcourse";
}
// Calling the function
funclfc();
?>
A. This is lfc
B. This is letsfindcourse
C. No Output
D. Error
View Answer
Ans : B
Explanation: The output of the following PHP code This is letsfindcourse.
8. A function name is not case-sensitive?
<?php
function prolfc($num1, $num2, $num3)
{
$mul = $num1 * $num2 * $num3;
echo "The product is $mul";
}
prolfc(1, 2, 3, 4);
?>
A. 24
B. 8
C. 6
D. Error: to many argument.
View Answer
Ans : C
Explanation: The output of the following PHP code is 6.
9. Type Hinting was introduced in which version of PHP?
A. PHP 5.1
B. PHP 5
C. PHP 5.3
D. PHP 5.4
View Answer
Ans : B
Explanation: PHP 5 introduced the feature of type hinting. With the help of type hinting, we can specify the expected data type of an argument in a function declaration.
10. A function in PHP which starts with double underscore is known as __________.
A. Magic Function
B. Inbuilt Function
C. Default Function
D. User Defined Function
View Answer
Ans : A
Explanation: PHP functions that start with a double underscore - a "__" are called magic functions in PHP.
Also check :
Discussion