Date: 01/11/01
- Next message: James Moore: "RE: [PHP-DEV] PHP script source revealed on windows"
- Previous message: jpintoc <email protected>: "[PHP-DEV] PHP 4.0 Bug #8443 Updated: Segmentation Fault"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: lgordon <email protected>
Operating system: freeBSD
PHP version: 4.0.4
PHP Bug Type: Class/Object related
Bug description: a copy of the internal array elements is sometimes not made
<?php
// buggy.php
// If I leave both A1 and A2 commented out, the code works fine.
// If I uncomment A1 only, the code works as expected
// If I uncomment A2 only, the code does not work as expected
class Element
{
var $val;
function set_value($newval)
{
$this->val = $newval;
}
}
class Owner
{
var $elementArray;
function dump()
{
foreach ($this->elementArray as $index => $value)
{
print("index [$index] value [$value->val]<BR>");
}
}
}
$myOwner = new Owner();
$myOwner->elementArray[0] = new Element;
// -- A1 --
// this works as expected
$myOwner->elementArray[0]->val = 10;
// -- A2 --
// if this line is uncommented the code does not work as expected
//$myOwner->elementArray[0]->set_value(10);
print("dump myOwner<BR>");
$myOwner->dump();
print("<BR>");
print("make a copy of myOwner<BR>");
$copyOwner = $myOwner;
print("<BR>");
print("dump copyOwner<BR>");
$copyOwner->dump();
print("<BR>");
print("change copyOwner index 0 to 999999<BR>");
$copyOwner->elementArray[0]->val = 999999;
print("dump copyOwner<BR>");
$copyOwner->dump();
print("<BR>");
print("dump myOwner<BR>");
$myOwner->dump();
print("<BR>");
?>
-- Edit Bug report at: http://bugs.php.net/?id=8661&edit=1-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: James Moore: "RE: [PHP-DEV] PHP script source revealed on windows"
- Previous message: jpintoc <email protected>: "[PHP-DEV] PHP 4.0 Bug #8443 Updated: Segmentation Fault"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

