0
0
PHPprogramming~5 mins

Return values in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does a return value do in a PHP function?
A return value sends data back from a function to the place where the function was called. It lets the function give back a result.
Click to reveal answer
beginner
How do you return a value from a PHP function?
Use the return keyword followed by the value you want to send back. For example: return 5;
Click to reveal answer
beginner
What happens if a PHP function has no return statement?
The function returns NULL by default, meaning it does not send any specific value back.
Click to reveal answer
intermediate
Can a PHP function return different types of values?
Yes, a PHP function can return any type of value like numbers, strings, arrays, or even objects.
Click to reveal answer
intermediate
What is the effect of a return statement inside a PHP function?
It immediately stops the function and sends the specified value back to the caller.
Click to reveal answer
What keyword is used to send a value back from a PHP function?
Aecho
Breturn
Coutput
Dsend
What does a PHP function return if it has no return statement?
ANULL
B0
Cfalse
Dempty string
Which of these can a PHP function return?
AOnly numbers
BOnly strings
CAny data type like numbers, strings, arrays
DNothing
What happens after a return statement is executed in a PHP function?
AThe function continues running
BThe function pauses
CThe function restarts
DThe function stops and returns the value
Which of these is NOT a valid return value in PHP?
AA CSS style
BAn array
CA function call
DAn integer
Explain how the return statement works in a PHP function and why it is useful.
Think about how you get answers from a function after it runs.
You got /4 concepts.
    Describe what happens if a PHP function does not have a return statement.
    What does the function give back by default?
    You got /3 concepts.