Posts: 2,536
Location: Western Maryland
|
Quote:
|
Originally Posted by rungss
I can come out of the function as
return;
or return $value;
or return ($value);
|
This is true, but generally you want to write functions that always return the same data type. This is required in more strongly typed languages (e.g., C, Java), but in PHP you have some functionality. But your calling code must then determine what (if anything) was returned, introducing more complexity.
I would submit that if your function normally returns some object or value and you instead want to return from the function prematurely without a value, use -1 or null then check for those values in your calling code.
__________________
—Kyrnt
|