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


2. Which of the following is not a built-in function in php ?

A. print_r()
B. fopen()
C. fclosed()
D. gettype()

View Answer


3. Why should we use functions?

A. Reusability
B. Easier error detection
C. Easily maintained
D. All of the above

View Answer


4. A function name always begins with the keyword _________.

A. fun
B. def
C. function
D. None of the above

View Answer


5. A function name cannot start with a ____

A. alphabet
B. underscore
C. number
D. Both C and B

View Answer


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


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


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


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


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


11. PHP has over ____________ built-in functions that can be called directly.

A. 10
B. 100
C. 1000
D. 10000

View Answer


12. Function names are case-sensitive.

A. True
B. False
C. Only Built-In function
D. Only User-defined function

View Answer


13. how to declare strict requirement in php 7?

A. select(strict_types=1);
B. declare(strict_types=0);
C. declare(strict_types=1);
D. select(strict_types=0);

View Answer


14. where in code we declare strict requirement in php 7?

A. the very first line of the PHP file
B. the very last line of the PHP file
C. After declaring variable
D. Anywhere in the code.

View Answer


15. What will be the output of the following code?

<?php declare(strict_types=1); // strict requirement

function addNumbers(int $a, int $b) {
    return $a + $b;
}
echo addNumbers(5, "5 days"); 
?>

A. 5+5days
B. 55days
C. No Output
D. Error

View Answer


16. What will be the output of the following code?

<?php declare(strict_types=1); // strict requirement ?>


<?php
function setHeight(int $minheight = 50) {
    echo "The height is : $minheight <br>";
}

setHeight(350);

?>

A. The height is : 350
B. The height is : 50
C. No Output
D. Error

View Answer


17. Which one of the following functions displays PHP interpreter settings bound to web server?

A. infophp()
B. phpinfo()
C. php_info()
D. info_php()

View Answer


18. Which of the following functions help in navigating to another php page?

A. header()
B. location()
C. redirect()
D. None of the above

View Answer


19. In which of the following cases would function empty() return FALSE?

A. $x; echo empty($x);
B. $x=FALSE; echo empty($x);
C. $x=TRUE; echo empty($x);
D. $x=NULL; echo empty($x);

View Answer


20. What will be the output of the following code?

<?php

function WRITEMSG() {
    echo "Hello world!";
}

writemsg();
?>

A. Hello world!
B. Null
C. No Output
D. None of the above

View Answer





Also check :


Discussion


* You must be logged in to add comment.