#37731 [NEW]: internal reference becomes external
| From: | nhorton at gmail dot com | Date: | Wed, 07 Jun 2006 15:55:48 +0000 |
| Subject: | #37731 [NEW]: internal reference becomes external | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-98145@lists.php.net to get a copy of this message | ||
From: nhorton at gmail dot com
Operating system: xp
PHP version: 4.4.2
PHP Bug Type: Variables related
Bug description: internal reference becomes external
Description:
------------
this sure seems like a bug to me. referencing alpha to beta causes a
reference to be set up between all further iterations of the object.
delta, without the reference, behaves normally. i also tried it using
foreach loops instead of for loops, same thing happened.
Reproduce code:
---------------
class one{
function one($i){
$this->beta=$i;
$this->alpha=&$this->beta;
$this->delta='diamond';
}
}
for($i=0;$i<11;$i++){
$one= new one($i);
$array[]=$one;
}
for($i=0;$i<11;$i++){
$first_object=$array[$i];
$second_object=$first_object;
}
echo "<br>before loop<br>";
print_r($second_object);
for($i=0;$i<11;$i++){
$object=$array[$i];
$object->alpha='xxxx';
$object->delta='spade';
}
echo "<br>after loop<br>";
print_r($second_object);
Expected result:
----------------
expected output:
before loop
one Object ( [beta] => 10 [alpha] => 10 [delta] => diamond )
after loop
one Object ( [beta] => 10 [alpha] => 10 [delta] => diamond )
Actual result:
--------------
output:
before loop
one Object ( [beta] => 10 [alpha] => 10 [delta] => diamond )
after loop
one Object ( [beta] => xxxx [alpha] => xxxx [delta] => diamond )
--
Edit bug report at http://bugs.php.net/?id=37731&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37731&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37731&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37731&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37731&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37731&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37731&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37731&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37731&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37731&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37731&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37731&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37731&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37731&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37731&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37731&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37731&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37731&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37731&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37731&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37731&r=mysqlcfg