From: hamishcool3 at yahoo dot co dot uk Operating system: Windows XP PHP version: 5.2.3 PHP Bug Type: *General Issues Bug description: Undefined functions in classes
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 bug report at http://bugs.php.net/?id=41998&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41998&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41998&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41998&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41998&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41998&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41998&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41998&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41998&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41998&r=support Expected behavior: http://bugs.php.net/fix.php?id=41998&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41998&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41998&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41998&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41998&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41998&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41998&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41998&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41998&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41998&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41998&r=mysqlcfg