ID: 44681 Updated by: [EMAIL PROTECTED] Reported By: ilewis at uk dot ibm dot com -Status: Open +Status: Closed Bug Type: Arrays related Operating System: Windows XP SP2 PHP Version: 5.3CVS-2008-04-10 (snap) New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Just fixed the reported bug with resources used as offsets: $myarray[$fres]. They will still give "Illegal offset type" (as always) if used as an index in an array( ... ) construct. I wasn't sure if that should be changed to be consistent... Previous Comments: ------------------------------------------------------------------------ [2008-04-13 10:42:25] [EMAIL PROTECTED] This was introduced after the Jan 23rd changes to zend_execute.c, causing the resource ID to be read as a double. case statements just need to be rearranged. :-) I also noticed that trying to use a resource key like array($fres => 'bob') doesn't work (never has) and just gives "Illegal offset type." Seems like it should be consistent either way? The following patches also make that work, if they want to add it. http://realplain.com/php/bug44681.diff http://realplain.com/php/bug44681_5_3.diff ------------------------------------------------------------------------ [2008-04-10 09:32:56] ilewis at uk dot ibm dot com Description: ------------ Using todays prebuilt snap of 5.3 on Windows, it looks like resources being used as array keys are being converted to int(0). The prevents them being used as unique array keys. This is a big change from php 5.2.5, Reproduce code: --------------- <?php error_reporting(E_ALL | E_STRICT); $fres = fopen("g:/tmp/arraytest.php", "r"); $fres2 = fopen("g:/tmp/arraytest.phpb", "w"); var_dump($fres); var_dump($fres2); $myarray = array(1,2); var_dump($myarray); $myarray[$fres] = "bob"; $myarray[$fres2] = "bob2"; var_dump($myarray); ?> Expected result: ---------------- PHP Strict Standards: Resource ID#5 used as offset, casting to integer (5) in G:\tmp\arraytest.php on line 15 PHP Strict Standards: Resource ID#6 used as offset, casting to integer (6) in G:\tmp\arraytest.php on line 16 array(4) { [0]=> int(1) [1]=> int(2) [5]=> string(3) "bob" [6]=> string(4) "bob2" } Actual result: -------------- Strict Standards: Resource ID#5 used as offset, casting to integer (5) in G:\tmp\arraytest.php on line 15 Strict Standards: Resource ID#6 used as offset, casting to integer (6) in G:\tmp\arraytest.php on line 16 array(2) { [0]=> string(4) "bob2" [1]=> int(2) } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44681&edit=1