php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #31008 Possible bug in the example code
Submitted: 2004-12-07 12:35 UTC Modified: 2004-12-08 13:00 UTC
From: afjoijojifaj9foobar dot 5 dot rdancer at spamgourme Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2004-12-07 12:35 UTC] afjoijojifaj9foobar dot 5 dot rdancer at spamgourme
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;
       } 
   }
}
?> 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-07 16:17 UTC] goba@php.net
Docproblem.
 [2004-12-07 21:40 UTC] nlopess@php.net
Where is that code?
Tha page you specified doesn't have any example.
 [2004-12-07 22:59 UTC] philip@php.net
The code in question is actually here:

http://php.net/manual/en/language.oop.php
 [2004-12-08 13:00 UTC] nlopess@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:11 UTC] phpdocbot@php.net
Automatic comment on behalf of nlopess
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=e2c756356fbcd730fe1ee8f5ae3f97f6b056b3bf
Log: fix #31008: first example had a little bug
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 08:01:31 2025 UTC