Re: Bug #12350: Referencing multiple arrays in classes from inside methods doesn't work
| From: | teo at gecadsoftware dot com | Date: | Wed, 25 Jul 2001 09:27:02 +0000 |
| Subject: | Re: Bug #12350: Referencing multiple arrays in classes from inside methods doesn't work | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-60933@lists.php.net to get a copy of this message | ||
Hi m.stenzel!
On Tue, 24 Jul 2001, m.stenzel@dragondezign.de wrote:
> From: m.stenzel@dragondezign.de
> Operating system: W2K
> PHP version: 4.0.6
> PHP Bug Type: Class/Object related
> Bug description: Referencing multiple arrays in classes from inside methods doesn't work
>
> Configuration: IIS 4 dll with Win32 binaries
>
> Okay I'm new to the game so forgive me a small mistake but I have tested
> and reproduced this weird behavior for more than 6 hours.
>
> A class wrapping multiple array variables doesn't allow to access both
> arrays as individual references from inside a function.
>
> The following code does not what I expected from the language:
>
> class test {
> VAR $firstarray; // defining one array
> VAR $secondarray; // defining another array
>
> function testit () {
> $i = 0;
> while ($i < 14) {
> $this->$firstarray[$i] = uniqid ("test", false);
> $this->$secondarray[$i] = uniqid ("different", false);
that should be $this->firstarray and $this->secondarray.
the manual (www.php.net/manual/ I guess) is quite clear about it.
> echo "Set array #1, item $i to ".$this->$firstarray[$i]." and array
>
> I think i read the manual thorougly and haven't found a hint about this
> behavior :(
>
Chapter 13. Classes and Objects
class Cart {
var $items;
...
function remove_item ($artnr, $num) {
if ($this->items[$artnr] > $num) {
$this->items[$artnr] -= $num;
^... no $ here
-- teodor