RE: [PHP] Return or not to return, that is the question

2007-05-30 Thread Edward Kay
Just a quick straw-poll really: What is your take on using 'return' when you end a function, if you don't actually need to return a value? If you have to return say a true/false as the result of an operation, then it's an obvious choice. But what if all the function does is perform an

Re: [PHP] Return or not to return, that is the question

2007-05-30 Thread Dave Goodchild
If there is no need to return a value then I don't do so. However, the function is going to process something, and surely you should check that the processing has succeeded or failed?

Re: [PHP] Return or not to return, that is the question

2007-05-30 Thread Paul Scott
On Wed, 2007-05-30 at 12:20 +0100, Dave Goodchild wrote: If there is no need to return a value then I don't do so. However, the function is going to process something, and surely you should check that the processing has succeeded or failed? If you unit test, then returns become quite

Re: [PHP] Return or not to return, that is the question

2007-05-30 Thread Zoltán Németh
2007. 05. 30, szerda keltezéssel 11.52-kor Richard Davey ezt írta: Hi all, Just a quick straw-poll really: What is your take on using 'return' when you end a function, if you don't actually need to return a value? If you have to return say a true/false as the result of an operation,

RE: [PHP] Return or not to return, that is the question

2007-05-30 Thread Chris Boget
If there is no need to return a value then I don't do so. However, the function is going to process something, and surely you should check that the processing has succeeded or failed? This is precisely the point I was going to make. Unless an argument is passed in by reference for

Re: [PHP] Return or not to return, that is the question

2007-05-30 Thread Darren Whitlen
Chris Boget wrote: If there is no need to return a value then I don't do so. However, the function is going to process something, and surely you should check that the processing has succeeded or failed? This is precisely the point I was going to make. Unless an argument is passed in by

RE: [PHP] Return or not to return, that is the question

2007-05-30 Thread Jay Blanchard
[snip] All depends on the function. function someFunc(){ $this-counter++; if($this-counter 100) $this-counter = 0; } Something that simple wont need a return at all. [/snip] Classically this would need a return, because $this-counter is going to be less than 100 most of the

Re: [PHP] Return or not to return, that is the question

2007-05-30 Thread Richard Lynch
On Wed, May 30, 2007 5:52 am, Richard Davey wrote: Just a quick straw-poll really: What is your take on using 'return' when you end a function, if you don't actually need to return a value? If you have to return say a true/false as the result of an operation, then it's an obvious choice.

Re: [PHP] Return or not to return, that is the question

2007-05-30 Thread Paul Novitski
At 5/30/2007 05:41 AM, Richard Davey wrote: /* check connection */ if (mysqli_connect_errno()) { printf(Connect failed: %s\n, mysqli_connect_error()); exit(); } If that was wrapped in a function, sticking 'return false' within the connect_error check is useful why exactly? Equally the

Re: [PHP] Return or not to return, that is the question

2007-05-30 Thread Richard Lynch
On Wed, May 30, 2007 7:42 am, Darren Whitlen wrote: Chris Boget wrote: If there is no need to return a value then I don't do so. However, the function is going to process something, and surely you should check that the processing has succeeded or failed? This is precisely the point I was

RE: [PHP] Return or not to return, that is the question

2007-05-30 Thread Richard Lynch
On Wed, May 30, 2007 7:56 am, Jay Blanchard wrote: Classically this would need a return, because $this-counter is going to be less than 100 most of the time, and you may want to return the value at some point. Or you may not ever need to return it. And if you return it for no reason, you