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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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 time, and you may want to return the value
at some point.

Here is the thing (it is akin to all of the holy wars on brackets, etc),
the use of return has been pounded into old-schoolers heads for a long
time, regardless of the Boolean or value returned. It is good style and
it introduces consistency. As far as it being an extra line of code? So
be it! We're not in the day and age where we had to count CPU cycles! If
anyone is designing PHP applications with that level of granularity they
have entered into an amazingly pedantic process for which PHP is not
well suited.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux