PHP Control Structures return

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The return statement returns the program control to the calling function.

When return is called from within a function, the execution of the current function will end.

function returnEndsFunctions()
{
   echo 'This is executed';
   return;
   echo 'This is not executed.';
}

When you run returnEndsFunctions(); you'll get the output This is executed;

When return is called from within a function with and argument, the execution of the current function will end and the value of the argument will be returned to the calling function.



Got any PHP Question?