ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
#44681 [Opn]: Resources used as array keys get converted to 0
by mattwil other posts by this author
Apr 13 2008 3:42AM messages near this date
#44681 [Opn->Csd]: Resources used as array keys get converted to 0 | #44680 [NEW]: Can not dynamically load any extension on linux base on PPC
ID:               44681
 Updated by:       mattwil@[...].net
 Reported By:      ilewis at uk dot ibm dot com
 Status:           Open
 Bug Type:         Arrays related
 Operating System: Windows XP SP2
 PHP Version:      5.3CVS-2008-04-10 (snap)
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[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
Thread:
Ilewis At Uk Dot Ibm Dot Com
mattwil
mattwil

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved