ID:               41998
 Updated by:       [EMAIL PROTECTED]
 Reported By:      hamishcool3 at yahoo dot co dot uk
-Status:           Open
+Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Windows XP
 PHP Version:      5.2.3
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php




Previous Comments:
------------------------------------------------------------------------

[2007-07-15 08:29:53] hamishcool3 at yahoo dot co dot uk

Description:
------------
When functions are defined inside a class, the function seems to
undefine itself outside the class.

Reproduce code:
---------------
<?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;
        } elseif ($this->items[$artnr] == $num) {
            unset($this->items[$artnr]);
            return true;
        } else {
            return false;
        }
    }
}
add_item(1,12);
print_r($this);
?> 

Expected result:
----------------
Cart Object (
        [items] => Array (
                [1] => 12
        )
)

Actual result:
--------------
Fatal error: Call to undefined function add_item() in F:\webdocs\cp.php
on line 25


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41998&edit=1

Reply via email to