#24485 [Com]: $a = $b; become $a=&$b; when I use a function
From: svroemisse at yahoo dot com Date: Thu, 05 Feb 2004 10:34:03 +0000 Subject: #24485 [Com]: $a = $b; become $a=&$b; when I use a function References: 1 Groups: php.bugs Request: Send a blank email to php-bugs+get-54443@lists.php.net to get a copy of this message
ID: 24485
Comment by: svroemisse at yahoo dot com
Reported By: gomez at efrei dot fr
Status: Verified
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 4CVS, 5CVS
New Comment:
I am experiencing the same problems on 2 linux machines running PHP
4.3.4 and a Windows machine running an unknown cgi version on IIS (I
have no access to it right now). This seems to be a resurrection of
bugs #8130 and #6417.
Previous Comments:
------------------------------------------------------------------------
[2003-07-17 14:03:27] moriyoshi@php.net
The following piece produces a similar result:
<?php
class foo {}
$a = array(new foo());
function show(&$this) { return 5; }
show($a[0]);
var_dump($a);
?>
------------------------------------------------------------------------
[2003-07-03 10:17:47] gomez at efrei dot fr
Description:
------------
In an array, classes become classes references when I use a function
member.
Because of that, I don't copy it anymore, I just produce more pointers
to it.
(see the '&' in the var dump)
If you comment the magic line, the bug won't appear.
Tested under linux (php 4.1.2 and 4.2.3)
and windows (php 4.3.2)
Reproduce code:
---------------
<?php
class AAAAA {
var $value;
function AAAAA() {}
function show() { return 5; }
}
$A = array(new AAAAA());
$A[0]->show(); /* magic line */
$A[0]->value = 'A';
$B = $A;
$B[0]->value = 'B';
echo $A[0]->value.$B[0]->value;
echo "\n";
var_dump( $A );
?>
Expected result:
----------------
AB
array(1) {
[0]=>
object(aaaaa)(1) {
["value"]=>
string(1) "A"
}
}
Actual result:
--------------
BB
array(1) {
[0]=>
&object(aaaaa)(1) {
["value"]=>
string(1) "B"
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24485&edit=1
Thread (27 messages)
- #24485 [Opn->Ver]: $a = $b; become $a=&$b; when I use a function
- #24485 [Ver]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Ver]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Ver->Asn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Asn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Asn->Fbk]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [NoF->Opn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Opn->Fbk]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [NoF->Opn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Opn->Asn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Asn->Fbk]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [NoF->Opn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Com]: $a = $b; become $a=&$b; when I use a function
- #24485 [Opn->Asn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Asn->Opn]: $a = $b; become $a=&$b; when I use a function
- #24485 [Opn->WFx]: $a = $b; become $a=&$b; when I use a function (PHP 4 only!)
| « previous | php.bugs (#54443) | next » |
|---|