On Thu, Apr 23, 2009 at 08:12:47AM -0400, Peter van der Does wrote: > I tend to put my return value in a variable and at the end of the > function I have 1 return statement. > I have seen others doing returns in the middle of the function. > > Example how I do it: > function check($a) { > $return=''; > if ( is_array( $a ) ) { > $return='Array'; > } else { > $return='Not Array'; > } > return $return; > } > > Example of the other method: > function check($a) { > > if ( is_array( $a ) ) { > return ('Array'); > } else { > return ('Not Array'); > } > } > > What is your take? And is there any benefit to either method? As mentioned, this is a matter of style. However, in a lot of cases, in order to get the return at the very end, it's necessary to put endless if/else pairs in the function. That makes it hard to read the source. I'm sure there are purists out there who would insist the single return go at the end. But expediency and readability may dictate otherwise. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php