Posted by Oli Filth on 12/30/05 12:02
Lüpher Cypher said the following on 30/12/2005 01:12:
> So, basically I have
>
> global $global;
> $global = array();
>
> function reg(&$obj) {
> global $global;
> $global[count($global)] = &$obj;
> }
>
> class A {
> var $a;
> function A() {
> $this->a = 0;
> reg(&$this);
> }
>
> function inc() {
> $this->a += 2;
> }
> }
>
> This will not work:
>
> $a = new A();
> echo "$a->a ".$objs[0]->a."<br />";
> $a->inc();
> echo "$a->a ".$objs[0]->a."<br />";
> $a->inc();
> echo "$a->a ".$objs[0]->a."<br />";
>
> outputs
> 0 0
> 2 0
> 4 0
>
Yet another situation where turning on error reporting will enable you
to immediately find the silly mistake...
--
Oli
Navigation:
[Reply to this message]
|