note 68501 added to function.mysql-fetch-assoc
| From: | rinkevandenberg at osu1 dot php dot net | Date: | Sun, 30 Jul 2006 09:42:09 +0000 |
| Subject: | note 68501 added to function.mysql-fetch-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115338@lists.php.net to get a copy of this message | ||
I read someone posting 'I have the philosphy that a function has exactly one return
point.'
It seems to me that always having only one return point takes away a little power from
'return' making code less efficient. Compare:
function doSomething($a,$b) {
$returnVal = 1;
if($a==$b) { $returnVal = false; }
if($returnVal !== false) { //didnt we discover that already?
//do something as we know a and b is what we expect
$returnVal = $a - $b;
}
return $returnVal;
}
with:
function doSomething($a,$b) {
if($a==$b) { return false; //early exit }
//do something as we know a and b is what we expect
return $a-$b;
}
----
Server IP: 194.109.193.119
Probable Submitter: 84.82.64.236
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-assoc.php
Edit -- http://master.php.net/note/edit/68501
Del: integrated -- http://master.php.net/note/delete/68501/integrated
Del: useless -- http://master.php.net/note/delete/68501/useless
Del: bad code -- http://master.php.net/note/delete/68501/bad+code
Del: spam -- http://master.php.net/note/delete/68501/spam
Del: non-english -- http://master.php.net/note/delete/68501/non-english
Del: in docs -- http://master.php.net/note/delete/68501/in+docs
Del: other reasons-- http://master.php.net/note/delete/68501
Reject -- http://master.php.net/note/reject/68501
Search -- http://master.php.net/manage/user-notes.php