I have a snippet of code like this which works fine in PHP4.
$secs = array();
foreach($_GET['sids'] as $sid){
$secs[$sid] = new CustomSecurity();
$secs[$sid]->set(array('customSecurityID' => $sid));
}
However, in PHP5 (5.2.4) the array has the proper keys in it but all of
the array values in $secs seem to point to the same instance.
Basically, the customSecurityID value inside each array value (object
instance) should match the array key, but all of the customSecurityID
values are set to the last $sid value during the final iteration which
tells me the array values are not 3 separate instances, but references
to the same instance.
I'm having a hard time seeing how this isn't a bug. On each iteration
of the loop I'm using a new variable $secs[$sid] which is previously
unassigned and assigning it via the new operator to a new instance.
Is this a bug or a strange reference behavior that I don't understand?
How can you fill arrays with multiple new instances?
Thanks.
Dave
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php