What's the difference between `return;` and no return?
php code
<?php
function a() {
echo 1;
return;
}
function b() {
echo 2;
}
generated bytecode
.FUNCTION a
ECHO 1
RETURN NULL
RETURN NULL
HANDLE_EXCEPTION
.END FUNCTION
.FUNCTION b
ECHO 2
RETURN NULL
HANDLE_EXCEPTION
.END FUNCTION
so the explicit return statement generates one extra RETURN instruction. Otherwise there's no difference.
As far as I know there is no difference.
The empty return;
is mainly there to break out from a if/else, while or for loop without returning anything.
Functionally there's no difference but it's always nice to have an obvious point of exit in a function (the return). Some schools of computer science hold tht all functions and methods should have precisely 1, and only 1, point of exit.
Should you need to add a return value in the future then there's an obvious point already picked out for you in the code if you include an empty return.
But like I said, from a functional point of view there's not much difference.