I've seen lots of instances when a "return" is included at the end of function in PHP yet passes no value and therefore would return null. I know it also exits the function, but is that necessary or is the return superfluous/just a way for developers to communicate that the function doesn't return any value?
A code example:
// Check to see if the request is a HXR call
if (request::is_ajax())
{
// Send the 403 header
header('HTTP/1.1 403 Forbidden');
return;
}
See? Couldn't you take out the return; and have exactly the same functionality? Or, if there were other functions following this if statement, would they not run because the computer would be stuck in the if statement?
return(or, as the case may be,exit).