WorksheetsFUNCTION PHP
Total questions: 8
Worksheet time: 4mins
What is the purpose of a PHP function?
To store variables
To execute a specific task
To print HTML code
To create classes
Which keyword is used to declare a function in PHP?
method
func
def
function
Which of the following is true about function names in PHP?
They cannot start with a number
They cannot contain special characters
They are case-insensitive
They must always start with a dollar sign ($)
What does the keyword "return" do in a PHP function?
It terminates the function
It echoes a message
It sends a value back to the calling code
It generates an error
Which of the following statements about parameters in PHP functions is true?
Functions cannot accept parameters
Parameters are optional
Parameters are enclosed in curly braces {}
Parameters are placeholders for values passed to the function
What is the purpose of the "global" keyword in PHP functions?
To declare a variable as local to the function
To access a variable declared outside of the function
To define a constant
To include another PHP file
What is the default scope of a PHP function if no scope is specified?
Global
Local
Protected
Private
What is the purpose of the "static" keyword in a PHP function?
To define a constant
To declare a variable as local to the function
To retain the value of a variable between function calls
To include another PHP file
