Re: Multiple return statements in a function.
| From: | Per Jessen | Date: | Thu, 23 Apr 2009 14:09:18 +0000 |
| Subject: | Re: Multiple return statements in a function. | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-291868@lists.php.net to get a copy of this message | ||
Richard Heyes wrote:
> Hi,
>
>> while(true){
>
> Yikes.
>
> Personally, I'd put the return value wherever it will make the code
> easier to read. If you're checking what has been passed as arguments,
> and one of them is wrong, I think there's little point in continuing,
> so an immediate return is the order of the day.
Well, I usually use that construct where I can have a number of
different error-conditions - e.g. if I have a sequence of socket
create, DNS lookup, bind, connect etc.
/Per
--
Per Jessen, Zürich (15.6°C)