PHP return


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.