Date: 12/30/02
- Next message: moriyoshi <email protected>: "[PHP-DOC] #21288 [Opn]: PHP does referencing when i want to create a *copy* of an array of objects"
- Previous message: Audrius Karabanovas: "[PHP-DOC] CVS module"
- Next in thread: moriyoshi <email protected>: "[PHP-DOC] #21288 [Opn]: PHP does referencing when i want to create a *copy* of an array of objects"
- Maybe reply: moriyoshi <email protected>: "[PHP-DOC] #21288 [Opn]: PHP does referencing when i want to create a *copy* of an array of objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 21288
Updated by: moriyoshi <email protected>
Reported By: empx <email protected>
Status: Open
-Bug Type: Arrays related
+Bug Type: Documentation problem
Operating System: Windows XP SP1
PHP Version: 4.3.0
New Comment:
Verified. This is yet another "shallow copy" issue.
Previous Comments:
------------------------------------------------------------------------
[2002-12-30 06:52:59] empx <email protected>
Hello, i have some problems with understanding the following:
class Test {
var $a;
function Test() {
$this->a = 0;
}
function test2() {
}
}
$a[0] = new Test;
$b = $a;
$a[0]->a = 1;
echo($b[0]->a);
This outputs 0 as i would expect..but:
$a[0] = new Test;
$a[0]->test2();
$b = $a;
$a[0]->a = 1;
echo($b[0]->a);
This outputs 1, and i dont understand this, PHP seems to do some sort
of
referencing here, though i dont want any.. $b[0] = $a[0]; works and
creates
a real copy, but i was still wondering if $b = $a shouldnt create a
copy
aswell instead of this referencing stuff...
------------------------------------------------------------------------
-- Edit this bug report at http://bugs.php.net/?id=21288&edit=1-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: moriyoshi <email protected>: "[PHP-DOC] #21288 [Opn]: PHP does referencing when i want to create a *copy* of an array of objects"
- Previous message: Audrius Karabanovas: "[PHP-DOC] CVS module"
- Next in thread: moriyoshi <email protected>: "[PHP-DOC] #21288 [Opn]: PHP does referencing when i want to create a *copy* of an array of objects"
- Maybe reply: moriyoshi <email protected>: "[PHP-DOC] #21288 [Opn]: PHP does referencing when i want to create a *copy* of an array of objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

