#41998 [Opn->Bgs]: Undefined functions in classes
| From: | jani@php.net | Date: | Sun, 15 Jul 2007 11:12:18 +0000 |
| Subject: | #41998 [Opn->Bgs]: Undefined functions in classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115087@lists.php.net to get a copy of this message | ||
ID: 41998
Updated by: jani@php.net
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