Welcome to my series on every PHP keyword and its usage. Today’s item:
return keyword ends the current scope, and optionally passes a value back to the calling scope. It can be used inside of functions/methods, and in the global scope.
When used inside a function, the function will finish and the result will be passed back to the caller.
When used inside the global scope, it will end the current script. If the script was included from another script, the result will be passed back to the calling script.
Author Callum Muir