#31008 [NEW]: Possible bug in the example code
| From: | afjoijojifaj9foobar dot 5 dot rdancer at spamgourmet dot com | Date: | Tue, 07 Dec 2004 11:36:05 +0000 |
| Subject: | #31008 [NEW]: Possible bug in the example code | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-26766@lists.php.net to get a copy of this message | ||
From: afjoijojifaj9foobar dot 5 dot rdancer at spamgourmet dot com
Operating system:
PHP version: Irrelevant
PHP Bug Type: Website problem
Bug description: Possible bug in the example code
Description:
------------
The test in the remove_item() function should be
if ($this->items[$artnr] >= $num)
^^
Cheers,
Jan Minář
"http://uk2.php.net/manual/en/language.oop5.php":
<?php
class Cart {
var $items; // Items in our shopping cart
// Add $num articles of $artnr to the cart
function add_item($artnr, $num) {
$this->items[$artnr] += $num;
}
// Take $num articles of $artnr out of the cart
function remove_item($artnr, $num) {
if ($this->items[$artnr] > $num) {
$this->items[$artnr] -= $num;
return true;
} else {
return false;
}
}
}
?>
--
Edit bug report at http://bugs.php.net/?id=31008&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31008&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31008&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31008&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31008&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31008&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31008&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31008&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31008&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31008&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31008&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31008&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31008&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31008&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31008&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31008&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31008&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31008&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31008&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31008&r=mysqlcfg