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

First, there are NO pointers in PHP, these are called references,
please stick to this term.

Second, yes, variables in a function imported from the global namespace
are in fact references to the global variables. So if working with
references on references in this context does not work.

For objects, you should be out of trouble in PHP5/ZE2 as they aren't
copied anymore so you don't need a reference to them.


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

[2002-04-20 10:43:56] [EMAIL PROTECTED]

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 ?

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

[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