ID:               16712
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         Class/Object related
 Operating System: Linux RedHat 7.2
 PHP Version:      4.1.2
 New Comment:

The assignment does work while staying local btw... so an echo $b->v;
within ta() would display 1 as it should.

I'm not sure about the exact implementation of PHP, but i think globals
ARE pointers, right ? That would explain it (though i'm not happy with
it).
If so the line 
    global $b;
would do the same as 
    $b(local) =& $b(global);
and thus a reassignment of $b to another point would seperate him from
$b(global).

Still i would like to re-reference my $b(global) in a local function.
Is there maybe a workaround or is it an impossibility ?


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

[2002-04-20 10:31:48] [EMAIL PROTECTED]

While using classes, pointers and globals I noticed data not being
migrated to the globalsphere due to pointerassignments.

[Example]

class test {
    var $v=0;
    function set($i) { $this->v = $i; }
}

$a = new test();
$b =& new test();
$c =& $b;
function ta() {
 global $a,$b,$c;
 $a->set(1);
 $b =& $a;
 $c->set(2);
}
ta();
echo "$a->v,$b->v,$c->v";

[/example]

This should display 1,1,2 since $b has been set to $a, but this
pointer-assigment isn't emigrated to the global $b.

I have done many expirements with it to see if i could further specify
the bug... at first i thought it was destroying non-globals that got
pointed too at the end of the functioncall and thus (accidently)
destroying the pointers in the process, but then if i would point $a to
$b and export them both, neither should be destroyed, so the reference
should stay intact... it isn't.

So the only thing that remains is that function-local
pointer-assigments not seem to affect my global var.

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


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

Reply via email to