ID: 35267 User updated by: mdunn at escindex dot com Reported By: mdunn at escindex dot com Status: Bogus Bug Type: Arrays related Operating System: FreeBSD 4.10 PHP Version: 5.0.5 New Comment:
Unless you are referring to the -> "referencing" a variable, it is a bug. We have 2 "live" servers. On server 1 (PHP4), the script runs (even with the missing =) and DOES NOT change the value. On server 2 (PHP5) the script runs and DOES change the value. Once we add in the second =, both scripts run as expected. So our logic error compounded with the addition of PHP5 overwrites the value. No where in the documentation does it mention this for PHP4 or PHP5. Even if it wasn't a logic error, and we really wanted to set the "copy" of the value to 1, it SHOULD NOT change the master value. Previous Comments: ------------------------------------------------------------------------ [2005-11-17 18:35:14] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. $item->product_id = 1 <- ------------------------------------------------------------------------ [2005-11-17 18:19:40] mdunn at escindex dot com Description: ------------ According to the documentation "foreach" operates on a copy of the specified array and not the array itself. I believe that in PHP5 something has been messed up as it works in PHP4. There was a logic error in our script (missing double ==), however in PHP4 it had no effect on the outcome. In PHP5 it actually changed the value. Screen shots available at http://ww1.escindex.com/phpbug/ Reproduce code: --------------- $items['product_type'] = 'CPKG'; $items['product_id'] = 2; foreach($items as $item) { if($item->product_type == 'CPKG' && ($item->product_id = 1 || $item->product_id == 2)) { Expected result: ---------------- $items['product_type'] = 'CPKG'; $items['product_id'] = 2; Actual result: -------------- $items['product_type'] = 'CPKG'; $items['product_id'] = 1; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35267&edit=1
