In this tutorial, we’ll see different uses of return statement in PHP with examples.
But believe me, this will create new opportunities of using return statement in different part of the codebase and we’ll understand how dynamically we can use it in our day to day coding.
In short, once the PHP interpreter reached at the return statement then the return statement immediately ends the current execution of the function, and the value passed as an argument to the return is returned to the function call.
So in file1.php, we have defined a return statement and in another file we included that file and assigned that to $employeeInfo variable and then we can perform whatever the action we want to take.
We have seen different Uses of return statement in PHP but the fact is that we in general use only one form of the return statement i.e., in function only.