From:             [EMAIL PROTECTED]
Operating system: Linux 2.4
PHP version:      4.2.0
PHP Bug Type:     Class/Object related
Bug description:  Scope loss when using layered/arrayed objects.

I am having difficulty writing a test case for this problem, as it is
somewhat complex. Here is the scenario:

I have an object that contains an array of data. Some array elements may
be scalar, some arrays and some objects. The object of the array contains
in itself another array of objects (containing core data) and accessor
methods to act on the data objects. My script uses the following
methodology on this object:

$var = "PHP Rules";
$test = "";
while ($mydata = $obj->arrayname[object_key]->fields) {
  // Do some work
  $test = "HERE I AM!";
  $var .= $mydata[xyz] . "MODIFIED";
  $obj->arrayname[object_key]->MoveNext();
}
print "$var$test";

I might get concerned here that my object layering is too deep. However,
the key issue here is that $var and for that matter ANY variable used or
modified inside the while loop does not carry its changes outside. This
means the print statement outputs "PHP Rules" only. Adding prints inside
the while loop outputs fine. I will try to find a workaround for now.

Thanks for your help,
Fred


-- 
Edit bug report at http://bugs.php.net/?id=16954&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=16954&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=16954&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=16954&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=16954&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16954&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=16954&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=16954&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=16954&r=submittedtwice

Reply via email to